diff --git a/dll/win32/windowscodecs/bitmap.c b/dll/win32/windowscodecs/bitmap.c index a44f5bd7b39..7959da6911d 100644 --- a/dll/win32/windowscodecs/bitmap.c +++ b/dll/win32/windowscodecs/bitmap.c @@ -1,5 +1,6 @@ /* * Copyright 2012 Vincent Povirk for CodeWeavers + * Copyright 2016 Dmitry Timoshkov * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -16,7 +17,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#ifndef __REACTOS__ #include "config.h" +#endif #include @@ -28,6 +31,7 @@ #include "wincodecs_private.h" +#include "wine/asm.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(wincodecs); @@ -38,7 +42,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(wincodecs); typedef struct BitmapImpl { IMILUnknown1 IMILUnknown1_iface; LONG ref; - IMILBitmapSource IMILBitmapSource_iface; + IMILBitmap IMILBitmap_iface; IWICBitmap IWICBitmap_iface; IMILUnknown2 IMILUnknown2_iface; IWICPalette *palette; @@ -68,9 +72,9 @@ static inline BitmapImpl *impl_from_IWICBitmap(IWICBitmap *iface) return CONTAINING_RECORD(iface, BitmapImpl, IWICBitmap_iface); } -static inline BitmapImpl *impl_from_IMILBitmapSource(IMILBitmapSource *iface) +static inline BitmapImpl *impl_from_IMILBitmap(IMILBitmap *iface) { - return CONTAINING_RECORD(iface, BitmapImpl, IMILBitmapSource_iface); + return CONTAINING_RECORD(iface, BitmapImpl, IMILBitmap_iface); } static inline BitmapImpl *impl_from_IMILUnknown1(IMILUnknown1 *iface) @@ -254,7 +258,7 @@ static HRESULT WINAPI BitmapImpl_QueryInterface(IWICBitmap *iface, REFIID iid, else if (IsEqualIID(&IID_IMILBitmap, iid) || IsEqualIID(&IID_IMILBitmapSource, iid)) { - *ppv = &This->IMILBitmapSource_iface; + *ppv = &This->IMILBitmap_iface; } else { @@ -478,51 +482,30 @@ static const IWICBitmapVtbl BitmapImpl_Vtbl = { BitmapImpl_SetResolution }; -static HRESULT WINAPI IMILBitmapImpl_QueryInterface(IMILBitmapSource *iface, REFIID iid, +static HRESULT WINAPI IMILBitmapImpl_QueryInterface(IMILBitmap *iface, REFIID iid, void **ppv) { - BitmapImpl *This = impl_from_IMILBitmapSource(iface); + BitmapImpl *This = impl_from_IMILBitmap(iface); TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv); - - if (!ppv) return E_INVALIDARG; - - if (IsEqualIID(&IID_IUnknown, iid) || - IsEqualIID(&IID_IMILBitmap, iid) || - IsEqualIID(&IID_IMILBitmapSource, iid)) - { - IUnknown_AddRef(&This->IMILBitmapSource_iface); - *ppv = &This->IMILBitmapSource_iface; - return S_OK; - } - else if (IsEqualIID(&IID_IWICBitmap, iid) || - IsEqualIID(&IID_IWICBitmapSource, iid)) - { - IUnknown_AddRef(&This->IWICBitmap_iface); - *ppv = &This->IWICBitmap_iface; - return S_OK; - } - - FIXME("unknown interface %s\n", debugstr_guid(iid)); - *ppv = NULL; - return E_NOINTERFACE; + return IWICBitmap_QueryInterface(&This->IWICBitmap_iface, iid, ppv); } -static ULONG WINAPI IMILBitmapImpl_AddRef(IMILBitmapSource *iface) +static ULONG WINAPI IMILBitmapImpl_AddRef(IMILBitmap *iface) { - BitmapImpl *This = impl_from_IMILBitmapSource(iface); + BitmapImpl *This = impl_from_IMILBitmap(iface); return IWICBitmap_AddRef(&This->IWICBitmap_iface); } -static ULONG WINAPI IMILBitmapImpl_Release(IMILBitmapSource *iface) +static ULONG WINAPI IMILBitmapImpl_Release(IMILBitmap *iface) { - BitmapImpl *This = impl_from_IMILBitmapSource(iface); + BitmapImpl *This = impl_from_IMILBitmap(iface); return IWICBitmap_Release(&This->IWICBitmap_iface); } -static HRESULT WINAPI IMILBitmapImpl_GetSize(IMILBitmapSource *iface, +static HRESULT WINAPI IMILBitmapImpl_GetSize(IMILBitmap *iface, UINT *width, UINT *height) { - BitmapImpl *This = impl_from_IMILBitmapSource(iface); + BitmapImpl *This = impl_from_IMILBitmap(iface); TRACE("(%p,%p,%p)\n", iface, width, height); return IWICBitmap_GetSize(&This->IWICBitmap_iface, width, height); } @@ -556,10 +539,10 @@ static const struct { &GUID_WICPixelFormat32bppCMYK, 0x1c } }; -static HRESULT WINAPI IMILBitmapImpl_GetPixelFormat(IMILBitmapSource *iface, +static HRESULT WINAPI IMILBitmapImpl_GetPixelFormat(IMILBitmap *iface, int *format) { - BitmapImpl *This = impl_from_IMILBitmapSource(iface); + BitmapImpl *This = impl_from_IMILBitmap(iface); int i; TRACE("(%p,%p)\n", iface, format); @@ -581,33 +564,33 @@ static HRESULT WINAPI IMILBitmapImpl_GetPixelFormat(IMILBitmapSource *iface, return S_OK; } -static HRESULT WINAPI IMILBitmapImpl_GetResolution(IMILBitmapSource *iface, +static HRESULT WINAPI IMILBitmapImpl_GetResolution(IMILBitmap *iface, double *dpix, double *dpiy) { - BitmapImpl *This = impl_from_IMILBitmapSource(iface); + BitmapImpl *This = impl_from_IMILBitmap(iface); TRACE("(%p,%p,%p)\n", iface, dpix, dpiy); return IWICBitmap_GetResolution(&This->IWICBitmap_iface, dpix, dpiy); } -static HRESULT WINAPI IMILBitmapImpl_CopyPalette(IMILBitmapSource *iface, +static HRESULT WINAPI IMILBitmapImpl_CopyPalette(IMILBitmap *iface, IWICPalette *palette) { - BitmapImpl *This = impl_from_IMILBitmapSource(iface); + BitmapImpl *This = impl_from_IMILBitmap(iface); TRACE("(%p,%p)\n", iface, palette); return IWICBitmap_CopyPalette(&This->IWICBitmap_iface, palette); } -static HRESULT WINAPI IMILBitmapImpl_CopyPixels(IMILBitmapSource *iface, +static HRESULT WINAPI IMILBitmapImpl_CopyPixels(IMILBitmap *iface, const WICRect *rc, UINT stride, UINT size, BYTE *buffer) { - BitmapImpl *This = impl_from_IMILBitmapSource(iface); + BitmapImpl *This = impl_from_IMILBitmap(iface); TRACE("(%p,%p,%u,%u,%p)\n", iface, rc, stride, size, buffer); return IWICBitmap_CopyPixels(&This->IWICBitmap_iface, rc, stride, size, buffer); } -static HRESULT WINAPI IMILBitmapImpl_unknown1(IMILBitmapSource *iface, void **ppv) +static HRESULT WINAPI IMILBitmapImpl_unknown1(IMILBitmap *iface, void **ppv) { - BitmapImpl *This = impl_from_IMILBitmapSource(iface); + BitmapImpl *This = impl_from_IMILBitmap(iface); TRACE("(%p,%p)\n", iface, ppv); @@ -619,41 +602,41 @@ static HRESULT WINAPI IMILBitmapImpl_unknown1(IMILBitmapSource *iface, void **pp return S_OK; } -static HRESULT WINAPI IMILBitmapImpl_Lock(IMILBitmapSource *iface, const WICRect *rc, DWORD flags, IWICBitmapLock **lock) +static HRESULT WINAPI IMILBitmapImpl_Lock(IMILBitmap *iface, const WICRect *rc, DWORD flags, IWICBitmapLock **lock) { - BitmapImpl *This = impl_from_IMILBitmapSource(iface); + BitmapImpl *This = impl_from_IMILBitmap(iface); TRACE("(%p,%p,%08x,%p)\n", iface, rc, flags, lock); return IWICBitmap_Lock(&This->IWICBitmap_iface, rc, flags, lock); } -static HRESULT WINAPI IMILBitmapImpl_Unlock(IMILBitmapSource *iface, IWICBitmapLock *lock) +static HRESULT WINAPI IMILBitmapImpl_Unlock(IMILBitmap *iface, IWICBitmapLock *lock) { TRACE("(%p,%p)\n", iface, lock); IWICBitmapLock_Release(lock); return S_OK; } -static HRESULT WINAPI IMILBitmapImpl_SetPalette(IMILBitmapSource *iface, IWICPalette *palette) +static HRESULT WINAPI IMILBitmapImpl_SetPalette(IMILBitmap *iface, IWICPalette *palette) { - BitmapImpl *This = impl_from_IMILBitmapSource(iface); + BitmapImpl *This = impl_from_IMILBitmap(iface); TRACE("(%p,%p)\n", iface, palette); return IWICBitmap_SetPalette(&This->IWICBitmap_iface, palette); } -static HRESULT WINAPI IMILBitmapImpl_SetResolution(IMILBitmapSource *iface, double dpix, double dpiy) +static HRESULT WINAPI IMILBitmapImpl_SetResolution(IMILBitmap *iface, double dpix, double dpiy) { - BitmapImpl *This = impl_from_IMILBitmapSource(iface); + BitmapImpl *This = impl_from_IMILBitmap(iface); TRACE("(%p,%f,%f)\n", iface, dpix, dpiy); return IWICBitmap_SetResolution(&This->IWICBitmap_iface, dpix, dpiy); } -static HRESULT WINAPI IMILBitmapImpl_AddDirtyRect(IMILBitmapSource *iface, const WICRect *rc) +static HRESULT WINAPI IMILBitmapImpl_AddDirtyRect(IMILBitmap *iface, const WICRect *rc) { FIXME("(%p,%p): stub\n", iface, rc); return E_NOTIMPL; } -static const IMILBitmapSourceVtbl IMILBitmapImpl_Vtbl = +static const IMILBitmapVtbl IMILBitmapImpl_Vtbl = { IMILBitmapImpl_QueryInterface, IMILBitmapImpl_AddRef, @@ -674,6 +657,7 @@ static const IMILBitmapSourceVtbl IMILBitmapImpl_Vtbl = static HRESULT WINAPI IMILUnknown1Impl_QueryInterface(IMILUnknown1 *iface, REFIID iid, void **ppv) { + /* It's not clear what interface should be returned here */ FIXME("(%p,%s,%p): stub\n", iface, debugstr_guid(iid), ppv); *ppv = NULL; return E_NOINTERFACE; @@ -835,7 +819,7 @@ HRESULT BitmapImpl_Create(UINT uiWidth, UINT uiHeight, UINT stride, UINT datasiz } This->IWICBitmap_iface.lpVtbl = &BitmapImpl_Vtbl; - This->IMILBitmapSource_iface.lpVtbl = &IMILBitmapImpl_Vtbl; + This->IMILBitmap_iface.lpVtbl = &IMILBitmapImpl_Vtbl; This->IMILUnknown1_iface.lpVtbl = &IMILUnknown1Impl_Vtbl; This->IMILUnknown2_iface.lpVtbl = &IMILUnknown2Impl_Vtbl; This->ref = 1; diff --git a/dll/win32/windowscodecs/converter.c b/dll/win32/windowscodecs/converter.c index c3476c3efa4..dcc2f05693f 100644 --- a/dll/win32/windowscodecs/converter.c +++ b/dll/win32/windowscodecs/converter.c @@ -85,14 +85,6 @@ typedef struct FormatConverter { } FormatConverter; /* https://www.w3.org/Graphics/Color/srgb */ -#ifndef __REACTOS__ -static inline float from_sRGB_component(float f) -{ - if (f <= 0.04045f) return f / 12.92f; - return powf((f + 0.055f) / 1.055f, 2.4f); -} -#endif - static inline float to_sRGB_component(float f) { if (f <= 0.0031308f) return 12.92f * f; @@ -100,6 +92,12 @@ static inline float to_sRGB_component(float f) } #if 0 /* FIXME: enable once needed */ +static inline float from_sRGB_component(float f) +{ + if (f <= 0.04045f) return f / 12.92f; + return powf((f + 0.055f) / 1.055f, 2.4f); +} + static void from_sRGB(BYTE *bgr) { float r, g, b; @@ -460,8 +458,9 @@ static HRESULT copypixels_to_32bppBGRA(struct FormatConverter *This, const WICRe dstpixel=(DWORD*)dstrow; for (x=0; xWidth; x++) { + srcbyte++; *dstpixel++ = 0xff000000|(*srcbyte<<16)|(*srcbyte<<8)|*srcbyte; - srcbyte+=2; + srcbyte++; } srcrow += srcstride; dstrow += cbStride; @@ -778,9 +777,9 @@ static HRESULT copypixels_to_32bppBGRA(struct FormatConverter *This, const WICRe dstpixel=(DWORD*)dstrow; for (x=0; xWidth; x++) { BYTE red, green, blue; - red = *srcpixel++; srcpixel++; - green = *srcpixel++; srcpixel++; - blue = *srcpixel++; srcpixel++; + srcpixel++; red = *srcpixel++; + srcpixel++; green = *srcpixel++; + srcpixel++; blue = *srcpixel++; *dstpixel++=0xff000000|red<<16|green<<8|blue; } srcrow += srcstride; @@ -822,10 +821,10 @@ static HRESULT copypixels_to_32bppBGRA(struct FormatConverter *This, const WICRe dstpixel=(DWORD*)dstrow; for (x=0; xWidth; x++) { BYTE red, green, blue, alpha; - red = *srcpixel++; srcpixel++; - green = *srcpixel++; srcpixel++; - blue = *srcpixel++; srcpixel++; - alpha = *srcpixel++; srcpixel++; + srcpixel++; red = *srcpixel++; + srcpixel++; green = *srcpixel++; + srcpixel++; blue = *srcpixel++; + srcpixel++; alpha = *srcpixel++; *dstpixel++=alpha<<24|red<<16|green<<8|blue; } srcrow += srcstride; @@ -872,11 +871,47 @@ static HRESULT copypixels_to_32bppRGBA(struct FormatConverter *This, const WICRe switch (source_format) { case format_32bppRGB: + if (prc) + { + INT x, y; + + hr = IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer); + if (FAILED(hr)) return hr; + + /* set all alpha values to 255 */ + for (y=0; yHeight; y++) + for (x=0; xWidth; x++) + pbBuffer[cbStride*y+4*x+3] = 0xff; + } + return S_OK; + case format_32bppRGBA: - case format_32bppPRGBA: if (prc) return IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer); return S_OK; + + case format_32bppPRGBA: + if (prc) + { + INT x, y; + + hr = IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer); + if (FAILED(hr)) return hr; + + for (y=0; yHeight; y++) + for (x=0; xWidth; x++) + { + BYTE alpha = pbBuffer[cbStride*y+4*x+3]; + if (alpha != 0 && alpha != 255) + { + pbBuffer[cbStride*y+4*x] = pbBuffer[cbStride*y+4*x] * 255 / alpha; + pbBuffer[cbStride*y+4*x+1] = pbBuffer[cbStride*y+4*x+1] * 255 / alpha; + pbBuffer[cbStride*y+4*x+2] = pbBuffer[cbStride*y+4*x+2] * 255 / alpha; + } + } + } + return S_OK; + default: hr = copypixels_to_32bppBGRA(This, prc, cbStride, cbBufferSize, pbBuffer, source_format); if (SUCCEEDED(hr) && prc) @@ -1304,6 +1339,9 @@ static HRESULT copypixels_to_8bppGray(struct FormatConverter *This, const WICRec return hr; } + if (!prc) + return copypixels_to_24bppBGR(This, NULL, cbStride, cbBufferSize, pbBuffer, source_format); + srcstride = 3 * prc->Width; srcdatasize = srcstride * prc->Height; @@ -1311,7 +1349,7 @@ static HRESULT copypixels_to_8bppGray(struct FormatConverter *This, const WICRec if (!srcdata) return E_OUTOFMEMORY; hr = copypixels_to_24bppBGR(This, prc, srcstride, srcdatasize, srcdata, source_format); - if (SUCCEEDED(hr) && prc) + if (SUCCEEDED(hr)) { INT x, y; BYTE *src = srcdata, *dst = pbBuffer; @@ -1337,7 +1375,7 @@ static HRESULT copypixels_to_8bppGray(struct FormatConverter *This, const WICRec return hr; } -static UINT rgb_to_palette_index(BYTE r, BYTE g, BYTE b, WICColor *colors, UINT count) +static UINT rgb_to_palette_index(BYTE bgr[3], WICColor *colors, UINT count) { UINT best_diff, best_index, i; @@ -1347,15 +1385,15 @@ static UINT rgb_to_palette_index(BYTE r, BYTE g, BYTE b, WICColor *colors, UINT for (i = 0; i < count; i++) { BYTE pal_r, pal_g, pal_b; - DWORD diff_r, diff_g, diff_b, diff; + UINT diff_r, diff_g, diff_b, diff; pal_r = colors[i] >> 16; pal_g = colors[i] >> 8; pal_b = colors[i]; - diff_r = r - pal_r; - diff_g = g - pal_g; - diff_b = b - pal_b; + diff_r = bgr[2] - pal_r; + diff_g = bgr[1] - pal_g; + diff_b = bgr[0] - pal_b; diff = diff_r * diff_r + diff_g * diff_g + diff_b * diff_b; if (diff == 0) return i; @@ -1386,6 +1424,9 @@ static HRESULT copypixels_to_8bppIndexed(struct FormatConverter *This, const WIC return S_OK; } + if (!prc) + return copypixels_to_24bppBGR(This, NULL, cbStride, cbBufferSize, pbBuffer, source_format); + if (!This->palette) return WINCODEC_ERR_WRONGSTATE; hr = IWICPalette_GetColors(This->palette, 256, colors, &count); @@ -1398,7 +1439,7 @@ static HRESULT copypixels_to_8bppIndexed(struct FormatConverter *This, const WIC if (!srcdata) return E_OUTOFMEMORY; hr = copypixels_to_24bppBGR(This, prc, srcstride, srcdatasize, srcdata, source_format); - if (SUCCEEDED(hr) && prc) + if (SUCCEEDED(hr)) { INT x, y; BYTE *src = srcdata, *dst = pbBuffer; @@ -1409,7 +1450,7 @@ static HRESULT copypixels_to_8bppIndexed(struct FormatConverter *This, const WIC for (x = 0; x < prc->Width; x++) { - dst[x] = rgb_to_palette_index(bgr[2], bgr[1], bgr[0], colors, count); + dst[x] = rgb_to_palette_index(bgr, colors, count); bgr += 3; } src += srcstride; diff --git a/dll/win32/windowscodecs/icnsformat.c b/dll/win32/windowscodecs/icnsformat.c index 02e8ee97e6d..8194bc508a5 100644 --- a/dll/win32/windowscodecs/icnsformat.c +++ b/dll/win32/windowscodecs/icnsformat.c @@ -75,7 +75,6 @@ #undef SetRect #undef ShowCursor #undef UnionRect -#undef DPRINTF #endif #define COBJMACROS diff --git a/dll/win32/windowscodecs/metadataquery.c b/dll/win32/windowscodecs/metadataquery.c index c4c188d8c9d..79340427547 100644 --- a/dll/win32/windowscodecs/metadataquery.c +++ b/dll/win32/windowscodecs/metadataquery.c @@ -242,7 +242,6 @@ static HRESULT get_token(struct string_t *elem, PROPVARIANT *id, PROPVARIANT *sc bstr = next_token.u.bstrVal; end++; - p = end; while (*end && *end != '}' && end - start < elem->len) { if (*end == '\\') end++; @@ -925,7 +924,7 @@ HRESULT WINAPI WICMapSchemaToName(REFGUID format, LPWSTR schema, UINT len, WCHAR return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); } - if (ret_len) *ret_len = lstrlenW(name2schema[i].name) + 1; + *ret_len = lstrlenW(name2schema[i].name) + 1; return S_OK; } } diff --git a/dll/win32/windowscodecs/msvc.h b/dll/win32/windowscodecs/msvc.h index a694b8601bb..6bb78f43af6 100644 --- a/dll/win32/windowscodecs/msvc.h +++ b/dll/win32/windowscodecs/msvc.h @@ -1,6 +1,4 @@ -#define __ASM_STDCALL_FUNC(name,args,code) - #define typeof(X_) __typeof_ ## X_ struct IMILUnknown1; diff --git a/dll/win32/windowscodecs/palette.c b/dll/win32/windowscodecs/palette.c index 1c1e85834b8..f99cbe00fd1 100644 --- a/dll/win32/windowscodecs/palette.c +++ b/dll/win32/windowscodecs/palette.c @@ -669,8 +669,8 @@ static HRESULT WINAPI PaletteImpl_InitializeFromBitmap(IWICPalette *palette, hr = IWICBitmapSource_GetPixelFormat(source, &format); if (hr != S_OK) return hr; - /* For interoperability with gdiplus where PixelFormat24bppRGB actully stored - * as BGR (and there is no a corresponding RGB format) we have to use 24bppBGR + /* For interoperability with gdiplus where PixelFormat24bppRGB is actually stored + * as BGR (and there is no corresponding RGB format), we have to use 24bppBGR * to avoid format conversions. */ if (!IsEqualGUID(&format, &GUID_WICPixelFormat24bppBGR)) diff --git a/dll/win32/windowscodecs/pngformat.c b/dll/win32/windowscodecs/pngformat.c index 7050c95121b..c0e272e86f0 100644 --- a/dll/win32/windowscodecs/pngformat.c +++ b/dll/win32/windowscodecs/pngformat.c @@ -332,6 +332,7 @@ MAKE_FUNCPTR(png_set_strip_16); MAKE_FUNCPTR(png_set_tRNS); MAKE_FUNCPTR(png_set_tRNS_to_alpha); MAKE_FUNCPTR(png_set_write_fn); +MAKE_FUNCPTR(png_set_swap); MAKE_FUNCPTR(png_read_end); MAKE_FUNCPTR(png_read_image); MAKE_FUNCPTR(png_read_info); @@ -398,6 +399,7 @@ static void *load_libpng(void) LOAD_FUNCPTR(png_set_tRNS); LOAD_FUNCPTR(png_set_tRNS_to_alpha); LOAD_FUNCPTR(png_set_write_fn); + LOAD_FUNCPTR(png_set_swap); LOAD_FUNCPTR(png_read_end); LOAD_FUNCPTR(png_read_image); LOAD_FUNCPTR(png_read_info); @@ -620,7 +622,6 @@ static HRESULT WINAPI PngDecoder_Initialize(IWICBitmapDecoder *iface, IStream *p if (setjmp(jmpbuf)) { ppng_destroy_read_struct(&This->png_ptr, &This->info_ptr, &This->end_info); - HeapFree(GetProcessHeap(), 0, row_pointers); This->png_ptr = NULL; hr = WINCODEC_ERR_UNKNOWNIMAGEFORMAT; goto end; @@ -643,6 +644,10 @@ static HRESULT WINAPI PngDecoder_Initialize(IWICBitmapDecoder *iface, IStream *p color_type = ppng_get_color_type(This->png_ptr, This->info_ptr); bit_depth = ppng_get_bit_depth(This->png_ptr, This->info_ptr); + /* PNGs with bit-depth greater than 8 are network byte order. Windows does not expect this. */ + if (bit_depth > 8) + ppng_set_swap(This->png_ptr); + /* check for color-keyed alpha */ transparency = ppng_get_tRNS(This->png_ptr, This->info_ptr, &trans, &num_trans, &trans_values); @@ -816,6 +821,8 @@ static HRESULT WINAPI PngDecoder_Initialize(IWICBitmapDecoder *iface, IStream *p end: LeaveCriticalSection(&This->lock); + HeapFree(GetProcessHeap(), 0, row_pointers); + return hr; } @@ -1642,6 +1649,10 @@ static HRESULT WINAPI PngFrameEncode_WritePixels(IWICBitmapFrameEncode *iface, } } + /* Tell PNG we need to byte swap if writing a >8-bpp image */ + if (This->format->bit_depth > 8) + ppng_set_swap(This->png_ptr); + ppng_set_IHDR(This->png_ptr, This->info_ptr, This->width, This->height, This->format->bit_depth, This->format->color_type, This->interlace ? PNG_INTERLACE_ADAM7 : PNG_INTERLACE_NONE, diff --git a/dll/win32/windowscodecs/precomp.h b/dll/win32/windowscodecs/precomp.h index 144e085e442..0d0ac5c7af7 100644 --- a/dll/win32/windowscodecs/precomp.h +++ b/dll/win32/windowscodecs/precomp.h @@ -2,9 +2,6 @@ #ifndef WINCODECS_PRECOMP_H #define WINCODECS_PRECOMP_H -#include -#include - #include #define WIN32_NO_STATUS diff --git a/dll/win32/windowscodecs/scaler.c b/dll/win32/windowscodecs/scaler.c index d19e219feab..d6e56d096ea 100644 --- a/dll/win32/windowscodecs/scaler.c +++ b/dll/win32/windowscodecs/scaler.c @@ -1,5 +1,6 @@ /* * Copyright 2010 Vincent Povirk for CodeWeavers + * Copyright 2016 Dmitry Timoshkov * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -224,7 +225,7 @@ static HRESULT WINAPI BitmapScaler_CopyPixels(IWICBitmapScaler *iface, if (!This->source) { - hr = WINCODEC_ERR_WRONGSTATE; + hr = WINCODEC_ERR_NOTINITIALIZED; goto end; } @@ -395,30 +396,8 @@ static HRESULT WINAPI IMILBitmapScaler_QueryInterface(IMILBitmapScaler *iface, R void **ppv) { BitmapScaler *This = impl_from_IMILBitmapScaler(iface); - TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv); - - if (!ppv) return E_INVALIDARG; - - if (IsEqualIID(&IID_IUnknown, iid) || - IsEqualIID(&IID_IMILBitmapScaler, iid) || - IsEqualIID(&IID_IMILBitmapSource, iid)) - { - IUnknown_AddRef(&This->IMILBitmapScaler_iface); - *ppv = &This->IMILBitmapScaler_iface; - return S_OK; - } - else if (IsEqualIID(&IID_IWICBitmapScaler, iid) || - IsEqualIID(&IID_IWICBitmapSource, iid)) - { - IUnknown_AddRef(&This->IWICBitmapScaler_iface); - *ppv = &This->IWICBitmapScaler_iface; - return S_OK; - } - - FIXME("unknown interface %s\n", debugstr_guid(iid)); - *ppv = NULL; - return E_NOINTERFACE; + return IWICBitmapScaler_QueryInterface(&This->IWICBitmapScaler_iface, iid, ppv); } static ULONG WINAPI IMILBitmapScaler_AddRef(IMILBitmapScaler *iface) @@ -437,12 +416,7 @@ static HRESULT WINAPI IMILBitmapScaler_GetSize(IMILBitmapScaler *iface, UINT *width, UINT *height) { BitmapScaler *This = impl_from_IMILBitmapScaler(iface); - TRACE("(%p,%p,%p)\n", iface, width, height); - - if (!This->source) - return WINCODEC_ERR_NOTINITIALIZED; - return IWICBitmapScaler_GetSize(&This->IWICBitmapScaler_iface, width, height); } @@ -473,12 +447,7 @@ static HRESULT WINAPI IMILBitmapScaler_GetResolution(IMILBitmapScaler *iface, double *dpix, double *dpiy) { BitmapScaler *This = impl_from_IMILBitmapScaler(iface); - TRACE("(%p,%p,%p)\n", iface, dpix, dpiy); - - if (!This->source) - return WINCODEC_ERR_NOTINITIALIZED; - return IWICBitmapScaler_GetResolution(&This->IWICBitmapScaler_iface, dpix, dpiy); } @@ -499,12 +468,7 @@ static HRESULT WINAPI IMILBitmapScaler_CopyPixels(IMILBitmapScaler *iface, const WICRect *rc, UINT stride, UINT size, BYTE *buffer) { BitmapScaler *This = impl_from_IMILBitmapScaler(iface); - TRACE("(%p,%p,%u,%u,%p)\n", iface, rc, stride, size, buffer); - - if (!This->source) - return WINCODEC_ERR_NOTINITIALIZED; - return IWICBitmapScaler_CopyPixels(&This->IWICBitmapScaler_iface, rc, stride, size, buffer); } diff --git a/dll/win32/windowscodecs/tiffformat.c b/dll/win32/windowscodecs/tiffformat.c index d9b7c4c6096..6f4f6d06b74 100644 --- a/dll/win32/windowscodecs/tiffformat.c +++ b/dll/win32/windowscodecs/tiffformat.c @@ -289,6 +289,7 @@ static HRESULT tiff_get_decode_info(TIFF *tiff, tiff_decode_info *decode_info) decode_info->reverse_bgr = 0; decode_info->invert_grayscale = 0; decode_info->tiled = 0; + decode_info->source_bpp = 0; ret = pTIFFGetField(tiff, TIFFTAG_PHOTOMETRIC, &photometric); if (!ret) diff --git a/dll/win32/windowscodecs/typeof.h b/dll/win32/windowscodecs/typeof.h index b20434b7cce..91995864ac2 100644 --- a/dll/win32/windowscodecs/typeof.h +++ b/dll/win32/windowscodecs/typeof.h @@ -81,6 +81,7 @@ typedef void (__cdecl typeof(png_set_crc_action))(struct png_struct_def *, int, typedef void (__cdecl typeof(png_set_PLTE))(struct png_struct_def *, struct png_info_def *, const struct png_color_struct *, int); typedef void (__cdecl typeof(png_set_tRNS))(struct png_struct_def *, struct png_info_def *, const unsigned char *, int, const struct png_color_16_struct *); typedef void (__cdecl typeof(png_set_filter))(struct png_struct_def *, int, int); +typedef void (__cdecl typeof(png_set_swap))(struct png_struct_def *); typedef void *thandle_t_1; typedef __typeof_intptr (*TIFFReadWriteProc_1)(thandle_t_1, void *, __typeof_intptr); typedef unsigned int (*TIFFSeekProc_1)(void *, unsigned int, int); diff --git a/dll/win32/windowscodecs/wincodecs_private.h b/dll/win32/windowscodecs/wincodecs_private.h index 22af9a12fbb..ff192c26399 100644 --- a/dll/win32/windowscodecs/wincodecs_private.h +++ b/dll/win32/windowscodecs/wincodecs_private.h @@ -53,7 +53,23 @@ DECLARE_INTERFACE_(IMILBitmapSource,IUnknown) STDMETHOD_(HRESULT,GetResolution)(THIS_ double *,double *) PURE; STDMETHOD_(HRESULT,CopyPalette)(THIS_ IWICPalette *) PURE; STDMETHOD_(HRESULT,CopyPixels)(THIS_ const WICRect *,UINT,UINT,BYTE *) PURE; - /*** IMILBitmapSource methods ***/ +}; +#undef INTERFACE + +#define INTERFACE IMILBitmap +DECLARE_INTERFACE_(IMILBitmap,IMILBitmapSource) +{ + /*** IUnknown methods ***/ + STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID,void **) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + /*** IWICBitmapSource methods ***/ + STDMETHOD_(HRESULT,GetSize)(THIS_ UINT *,UINT *) PURE; + STDMETHOD_(HRESULT,GetPixelFormat)(THIS_ int *) PURE; + STDMETHOD_(HRESULT,GetResolution)(THIS_ double *,double *) PURE; + STDMETHOD_(HRESULT,CopyPalette)(THIS_ IWICPalette *) PURE; + STDMETHOD_(HRESULT,CopyPixels)(THIS_ const WICRect *,UINT,UINT,BYTE *) PURE; + /*** IMILBitmap methods ***/ STDMETHOD_(HRESULT,unknown1)(THIS_ void **) PURE; STDMETHOD_(HRESULT,Lock)(THIS_ const WICRect *,DWORD,IWICBitmapLock **) PURE; STDMETHOD_(HRESULT,Unlock)(THIS_ IWICBitmapLock *) PURE; @@ -64,7 +80,7 @@ DECLARE_INTERFACE_(IMILBitmapSource,IUnknown) #undef INTERFACE #define INTERFACE IMILBitmapScaler -DECLARE_INTERFACE_(IMILBitmapScaler,IUnknown) +DECLARE_INTERFACE_(IMILBitmapScaler,IMILBitmapSource) { /*** IUnknown methods ***/ STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID,void **) PURE; @@ -78,26 +94,11 @@ DECLARE_INTERFACE_(IMILBitmapScaler,IUnknown) STDMETHOD_(HRESULT,CopyPixels)(THIS_ const WICRect *,UINT,UINT,BYTE *) PURE; /*** IMILBitmapScaler methods ***/ STDMETHOD_(HRESULT,unknown1)(THIS_ void **) PURE; - STDMETHOD_(HRESULT,Initialize)(THIS_ IMILBitmapSource *,UINT,UINT,WICBitmapInterpolationMode); + STDMETHOD_(HRESULT,Initialize)(THIS_ IMILBitmapSource *,UINT,UINT,WICBitmapInterpolationMode) PURE; }; #undef INTERFACE -#ifdef __i386__ /* thiscall functions are i386-specific */ - -#define THISCALL(func) __thiscall_ ## func -#define DEFINE_THISCALL_WRAPPER(func,args) \ - extern typeof(func) THISCALL(func); \ - __ASM_STDCALL_FUNC(__thiscall_ ## func, args, \ - "popl %eax\n\t" \ - "pushl %ecx\n\t" \ - "pushl %eax\n\t" \ - "jmp " __ASM_NAME(#func) __ASM_STDCALL(args) ) -#else /* __i386__ */ - -#define THISCALL(func) func -#define DEFINE_THISCALL_WRAPPER(func,args) /* nothing */ - -#endif /* __i386__ */ +#define THISCALLMETHOD_(type,method) type (__thiscall *method) #define INTERFACE IMILUnknown1 DECLARE_INTERFACE_(IMILUnknown1,IUnknown) diff --git a/media/doc/README.WINE b/media/doc/README.WINE index def03896c75..876663af0de 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -197,7 +197,7 @@ dll/win32/version # Synced to WineStaging-4.18 dll/win32/vssapi # Synced to WineStaging-4.18 dll/win32/wbemdisp # Synced to WineStaging-4.18 dll/win32/wbemprox # Synced to WineStaging-4.18 -dll/win32/windowscodecs # Synced to WineStaging-4.0 +dll/win32/windowscodecs # Synced to WineStaging-4.18 dll/win32/windowscodecsext # Synced to WineStaging-2.9 dll/win32/winemp3.acm # Synced to WineStaging-3.3 dll/win32/wing32 # Synced to WineStaging-3.3