mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-09-02 04:13:34 +00:00
[WINDOWSCODECS]
* Sync with Wine 1.7.27. CORE-8540 svn path=/trunk/; revision=64615
This commit is contained in:
@@ -245,63 +245,22 @@ static HRESULT WINAPI BmpFrameEncode_WriteSource(IWICBitmapFrameEncode *iface,
|
||||
{
|
||||
BmpFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
|
||||
HRESULT hr;
|
||||
WICRect rc;
|
||||
WICPixelFormatGUID guid;
|
||||
TRACE("(%p,%p,%p)\n", iface, pIBitmapSource, prc);
|
||||
|
||||
if (!This->initialized || !This->width || !This->height)
|
||||
if (!This->initialized)
|
||||
return WINCODEC_ERR_WRONGSTATE;
|
||||
|
||||
if (!This->format)
|
||||
hr = configure_write_source(iface, pIBitmapSource, prc,
|
||||
This->format ? This->format->guid : NULL, This->width, This->height,
|
||||
This->xres, This->yres);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = IWICBitmapSource_GetPixelFormat(pIBitmapSource, &guid);
|
||||
if (FAILED(hr)) return hr;
|
||||
hr = BmpFrameEncode_SetPixelFormat(iface, &guid);
|
||||
if (FAILED(hr)) return hr;
|
||||
hr = write_source(iface, pIBitmapSource, prc,
|
||||
This->format->guid, This->format->bpp, This->width, This->height);
|
||||
}
|
||||
|
||||
hr = IWICBitmapSource_GetPixelFormat(pIBitmapSource, &guid);
|
||||
if (FAILED(hr)) return hr;
|
||||
if (memcmp(&guid, This->format->guid, sizeof(GUID)) != 0)
|
||||
{
|
||||
/* should use WICConvertBitmapSource to convert, but that's unimplemented */
|
||||
ERR("format %s unsupported\n", debugstr_guid(&guid));
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if (This->xres == 0.0 || This->yres == 0.0)
|
||||
{
|
||||
double xres, yres;
|
||||
hr = IWICBitmapSource_GetResolution(pIBitmapSource, &xres, &yres);
|
||||
if (FAILED(hr)) return hr;
|
||||
hr = BmpFrameEncode_SetResolution(iface, xres, yres);
|
||||
if (FAILED(hr)) return hr;
|
||||
}
|
||||
|
||||
if (!prc)
|
||||
{
|
||||
UINT width, height;
|
||||
hr = IWICBitmapSource_GetSize(pIBitmapSource, &width, &height);
|
||||
if (FAILED(hr)) return hr;
|
||||
rc.X = 0;
|
||||
rc.Y = 0;
|
||||
rc.Width = width;
|
||||
rc.Height = height;
|
||||
prc = &rc;
|
||||
}
|
||||
|
||||
if (prc->Width != This->width) return E_INVALIDARG;
|
||||
|
||||
hr = BmpFrameEncode_AllocateBits(This);
|
||||
if (FAILED(hr)) return hr;
|
||||
|
||||
hr = IWICBitmapSource_CopyPixels(pIBitmapSource, prc, This->stride,
|
||||
This->stride*(This->height-This->lineswritten),
|
||||
This->bits + This->stride*This->lineswritten);
|
||||
|
||||
This->lineswritten += prc->Height;
|
||||
|
||||
return S_OK;
|
||||
return hr;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BmpFrameEncode_Commit(IWICBitmapFrameEncode *iface)
|
||||
|
||||
@@ -374,66 +374,22 @@ static HRESULT WINAPI IcnsFrameEncode_WriteSource(IWICBitmapFrameEncode *iface,
|
||||
{
|
||||
IcnsFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
|
||||
HRESULT hr;
|
||||
WICRect rc;
|
||||
WICPixelFormatGUID guid;
|
||||
UINT stride;
|
||||
BYTE *pixeldata = NULL;
|
||||
|
||||
TRACE("(%p,%p,%p)\n", iface, pIBitmapSource, prc);
|
||||
|
||||
if (!This->initialized || !This->size)
|
||||
{
|
||||
hr = WINCODEC_ERR_WRONGSTATE;
|
||||
goto end;
|
||||
}
|
||||
if (!This->initialized)
|
||||
return WINCODEC_ERR_WRONGSTATE;
|
||||
|
||||
hr = IWICBitmapSource_GetPixelFormat(pIBitmapSource, &guid);
|
||||
if (FAILED(hr))
|
||||
goto end;
|
||||
if (!IsEqualGUID(&guid, &GUID_WICPixelFormat32bppBGRA))
|
||||
{
|
||||
FIXME("format %s unsupported, could use WICConvertBitmapSource to convert\n", debugstr_guid(&guid));
|
||||
hr = E_FAIL;
|
||||
goto end;
|
||||
}
|
||||
hr = configure_write_source(iface, pIBitmapSource, &prc,
|
||||
&GUID_WICPixelFormat32bppBGRA, This->size, This->size,
|
||||
1.0, 1.0);
|
||||
|
||||
if (!prc)
|
||||
{
|
||||
UINT width, height;
|
||||
hr = IWICBitmapSource_GetSize(pIBitmapSource, &width, &height);
|
||||
if (FAILED(hr))
|
||||
goto end;
|
||||
rc.X = 0;
|
||||
rc.Y = 0;
|
||||
rc.Width = width;
|
||||
rc.Height = height;
|
||||
prc = &rc;
|
||||
}
|
||||
|
||||
if (prc->Width != This->size)
|
||||
{
|
||||
hr = E_INVALIDARG;
|
||||
goto end;
|
||||
}
|
||||
|
||||
stride = (32 * This->size + 7)/8;
|
||||
pixeldata = HeapAlloc(GetProcessHeap(), 0, stride * prc->Height);
|
||||
if (!pixeldata)
|
||||
{
|
||||
hr = E_OUTOFMEMORY;
|
||||
goto end;
|
||||
}
|
||||
|
||||
hr = IWICBitmapSource_CopyPixels(pIBitmapSource, prc, stride,
|
||||
stride*prc->Height, pixeldata);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = IWICBitmapFrameEncode_WritePixels(iface, prc->Height, stride,
|
||||
stride*prc->Height, pixeldata);
|
||||
hr = write_source(iface, pIBitmapSource, prc,
|
||||
&GUID_WICPixelFormat32bppBGRA, 32, This->size, This->size);
|
||||
}
|
||||
|
||||
end:
|
||||
HeapFree(GetProcessHeap(), 0, pixeldata);
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
@@ -529,20 +529,22 @@ static HRESULT WINAPI ComponentFactory_CreateBitmapFromSource(IWICComponentFacto
|
||||
IWICBitmapLock_Release(lock);
|
||||
}
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
hr = PaletteImpl_Create(&palette);
|
||||
|
||||
if (SUCCEEDED(hr) && (format_type == WICPixelFormatNumericRepresentationUnspecified ||
|
||||
format_type == WICPixelFormatNumericRepresentationIndexed))
|
||||
{
|
||||
hr = IWICBitmapSource_CopyPalette(piBitmapSource, palette);
|
||||
hr = PaletteImpl_Create(&palette);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
hr = IWICBitmap_SetPalette(result, palette);
|
||||
else
|
||||
hr = S_OK;
|
||||
{
|
||||
hr = IWICBitmapSource_CopyPalette(piBitmapSource, palette);
|
||||
|
||||
IWICPalette_Release(palette);
|
||||
if (SUCCEEDED(hr))
|
||||
hr = IWICBitmap_SetPalette(result, palette);
|
||||
else
|
||||
hr = S_OK;
|
||||
|
||||
IWICPalette_Release(palette);
|
||||
}
|
||||
}
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
|
||||
@@ -1088,71 +1088,21 @@ static HRESULT WINAPI JpegEncoder_Frame_WriteSource(IWICBitmapFrameEncode *iface
|
||||
{
|
||||
JpegEncoder *This = impl_from_IWICBitmapFrameEncode(iface);
|
||||
HRESULT hr;
|
||||
WICRect rc;
|
||||
WICPixelFormatGUID guid;
|
||||
UINT stride;
|
||||
BYTE *pixeldata;
|
||||
TRACE("(%p,%p,%p)\n", iface, pIBitmapSource, prc);
|
||||
|
||||
if (!This->frame_initialized || !This->width || !This->height)
|
||||
if (!This->frame_initialized)
|
||||
return WINCODEC_ERR_WRONGSTATE;
|
||||
|
||||
if (!This->format)
|
||||
{
|
||||
hr = IWICBitmapSource_GetPixelFormat(pIBitmapSource, &guid);
|
||||
if (FAILED(hr)) return hr;
|
||||
hr = IWICBitmapFrameEncode_SetPixelFormat(iface, &guid);
|
||||
if (FAILED(hr)) return hr;
|
||||
}
|
||||
|
||||
hr = IWICBitmapSource_GetPixelFormat(pIBitmapSource, &guid);
|
||||
if (FAILED(hr)) return hr;
|
||||
if (memcmp(&guid, This->format->guid, sizeof(GUID)) != 0)
|
||||
{
|
||||
/* FIXME: should use WICConvertBitmapSource to convert */
|
||||
ERR("format %s unsupported\n", debugstr_guid(&guid));
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if (This->xres == 0.0 || This->yres == 0.0)
|
||||
{
|
||||
double xres, yres;
|
||||
hr = IWICBitmapSource_GetResolution(pIBitmapSource, &xres, &yres);
|
||||
if (FAILED(hr)) return hr;
|
||||
hr = IWICBitmapFrameEncode_SetResolution(iface, xres, yres);
|
||||
if (FAILED(hr)) return hr;
|
||||
}
|
||||
|
||||
if (!prc)
|
||||
{
|
||||
UINT width, height;
|
||||
hr = IWICBitmapSource_GetSize(pIBitmapSource, &width, &height);
|
||||
if (FAILED(hr)) return hr;
|
||||
rc.X = 0;
|
||||
rc.Y = 0;
|
||||
rc.Width = width;
|
||||
rc.Height = height;
|
||||
prc = &rc;
|
||||
}
|
||||
|
||||
if (prc->Width != This->width) return E_INVALIDARG;
|
||||
|
||||
stride = (This->format->bpp * This->width + 7)/8;
|
||||
|
||||
pixeldata = HeapAlloc(GetProcessHeap(), 0, stride * prc->Height);
|
||||
if (!pixeldata) return E_OUTOFMEMORY;
|
||||
|
||||
hr = IWICBitmapSource_CopyPixels(pIBitmapSource, prc, stride,
|
||||
stride*prc->Height, pixeldata);
|
||||
hr = configure_write_source(iface, pIBitmapSource, prc,
|
||||
This->format ? This->format->guid : NULL, This->width, This->height,
|
||||
This->xres, This->yres);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = IWICBitmapFrameEncode_WritePixels(iface, prc->Height, stride,
|
||||
stride*prc->Height, pixeldata);
|
||||
hr = write_source(iface, pIBitmapSource, prc,
|
||||
This->format->guid, This->format->bpp, This->width, This->height);
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, pixeldata);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
@@ -103,6 +103,92 @@ HRESULT copy_pixels(UINT bpp, const BYTE *srcbuffer,
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT configure_write_source(IWICBitmapFrameEncode *iface,
|
||||
IWICBitmapSource *source, const WICRect *prc,
|
||||
const WICPixelFormatGUID *format,
|
||||
INT width, INT height, double xres, double yres)
|
||||
{
|
||||
HRESULT hr=S_OK;
|
||||
WICPixelFormatGUID src_format, dst_format;
|
||||
|
||||
if (width == 0 || height == 0)
|
||||
return WINCODEC_ERR_WRONGSTATE;
|
||||
|
||||
hr = IWICBitmapSource_GetPixelFormat(source, &src_format);
|
||||
if (FAILED(hr)) return hr;
|
||||
|
||||
if (!format)
|
||||
{
|
||||
dst_format = src_format;
|
||||
|
||||
hr = IWICBitmapFrameEncode_SetPixelFormat(iface, &dst_format);
|
||||
if (FAILED(hr)) return hr;
|
||||
|
||||
format = &dst_format;
|
||||
}
|
||||
|
||||
if (!IsEqualGUID(&src_format, format))
|
||||
{
|
||||
/* FIXME: should use WICConvertBitmapSource to convert */
|
||||
ERR("format %s unsupported\n", debugstr_guid(&src_format));
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if (xres == 0.0 || yres == 0.0)
|
||||
{
|
||||
hr = IWICBitmapSource_GetResolution(source, &xres, &yres);
|
||||
if (FAILED(hr)) return hr;
|
||||
hr = IWICBitmapFrameEncode_SetResolution(iface, xres, yres);
|
||||
if (FAILED(hr)) return hr;
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
HRESULT write_source(IWICBitmapFrameEncode *iface,
|
||||
IWICBitmapSource *source, const WICRect *prc,
|
||||
const WICPixelFormatGUID *format, UINT bpp,
|
||||
INT width, INT height)
|
||||
{
|
||||
HRESULT hr=S_OK;
|
||||
WICRect rc;
|
||||
UINT stride;
|
||||
BYTE* pixeldata;
|
||||
|
||||
if (!prc)
|
||||
{
|
||||
UINT src_width, src_height;
|
||||
hr = IWICBitmapSource_GetSize(source, &src_width, &src_height);
|
||||
if (FAILED(hr)) return hr;
|
||||
rc.X = 0;
|
||||
rc.Y = 0;
|
||||
rc.Width = src_width;
|
||||
rc.Height = src_height;
|
||||
prc = &rc;
|
||||
}
|
||||
|
||||
if (prc->Width != width || prc->Height <= 0)
|
||||
return E_INVALIDARG;
|
||||
|
||||
stride = (bpp * width + 7)/8;
|
||||
|
||||
pixeldata = HeapAlloc(GetProcessHeap(), 0, stride * prc->Height);
|
||||
if (!pixeldata) return E_OUTOFMEMORY;
|
||||
|
||||
hr = IWICBitmapSource_CopyPixels(source, prc, stride,
|
||||
stride*prc->Height, pixeldata);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = IWICBitmapFrameEncode_WritePixels(iface, prc->Height, stride,
|
||||
stride*prc->Height, pixeldata);
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, pixeldata);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
void reverse_bgr8(UINT bytesperpixel, LPBYTE bits, UINT width, UINT height, INT stride)
|
||||
{
|
||||
UINT x, y;
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#include <png.h>
|
||||
#endif
|
||||
|
||||
static const WCHAR wszPngInterlaceOption[] = {'I','n','t','e','r','l','a','c','e','O','p','t','i','o','n',0};
|
||||
|
||||
static HRESULT read_png_chunk(IStream *stream, BYTE *type, BYTE **data, ULONG *data_size)
|
||||
{
|
||||
BYTE header[8];
|
||||
@@ -164,6 +166,7 @@ MAKE_FUNCPTR(png_set_gray_1_2_4_to_8);
|
||||
#endif
|
||||
MAKE_FUNCPTR(png_set_filler);
|
||||
MAKE_FUNCPTR(png_set_gray_to_rgb);
|
||||
MAKE_FUNCPTR(png_set_interlace_handling);
|
||||
MAKE_FUNCPTR(png_set_IHDR);
|
||||
MAKE_FUNCPTR(png_set_pHYs);
|
||||
MAKE_FUNCPTR(png_set_read_fn);
|
||||
@@ -213,6 +216,7 @@ static void *load_libpng(void)
|
||||
#endif
|
||||
LOAD_FUNCPTR(png_set_filler);
|
||||
LOAD_FUNCPTR(png_set_gray_to_rgb);
|
||||
LOAD_FUNCPTR(png_set_interlace_handling);
|
||||
LOAD_FUNCPTR(png_set_IHDR);
|
||||
LOAD_FUNCPTR(png_set_pHYs);
|
||||
LOAD_FUNCPTR(png_set_read_fn);
|
||||
@@ -1041,6 +1045,10 @@ typedef struct PngEncoder {
|
||||
BOOL frame_committed;
|
||||
BOOL committed;
|
||||
CRITICAL_SECTION lock;
|
||||
BOOL interlace;
|
||||
BYTE *data;
|
||||
UINT stride;
|
||||
UINT passes;
|
||||
} PngEncoder;
|
||||
|
||||
static inline PngEncoder *impl_from_IWICBitmapEncoder(IWICBitmapEncoder *iface)
|
||||
@@ -1092,8 +1100,32 @@ static HRESULT WINAPI PngFrameEncode_Initialize(IWICBitmapFrameEncode *iface,
|
||||
IPropertyBag2 *pIEncoderOptions)
|
||||
{
|
||||
PngEncoder *This = impl_from_IWICBitmapFrameEncode(iface);
|
||||
BOOL interlace;
|
||||
PROPBAG2 opts[1]= {{0}};
|
||||
VARIANT opt_values[1];
|
||||
HRESULT opt_hres[1];
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("(%p,%p)\n", iface, pIEncoderOptions);
|
||||
|
||||
opts[0].pstrName = (LPOLESTR)wszPngInterlaceOption;
|
||||
opts[0].vt = VT_BOOL;
|
||||
|
||||
if (pIEncoderOptions)
|
||||
{
|
||||
hr = IPropertyBag2_Read(pIEncoderOptions, 1, opts, NULL, opt_values, opt_hres);
|
||||
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
}
|
||||
else
|
||||
memset(opt_values, 0, sizeof(opt_values));
|
||||
|
||||
if (V_VT(&opt_values[0]) == VT_EMPTY)
|
||||
interlace = FALSE;
|
||||
else
|
||||
interlace = (V_BOOL(&opt_values[0]) != 0);
|
||||
|
||||
EnterCriticalSection(&This->lock);
|
||||
|
||||
if (This->frame_initialized)
|
||||
@@ -1102,6 +1134,8 @@ static HRESULT WINAPI PngFrameEncode_Initialize(IWICBitmapFrameEncode *iface,
|
||||
return WINCODEC_ERR_WRONGSTATE;
|
||||
}
|
||||
|
||||
This->interlace = interlace;
|
||||
|
||||
This->frame_initialized = TRUE;
|
||||
|
||||
LeaveCriticalSection(&This->lock);
|
||||
@@ -1239,8 +1273,21 @@ static HRESULT WINAPI PngFrameEncode_WritePixels(IWICBitmapFrameEncode *iface,
|
||||
|
||||
if (!This->info_written)
|
||||
{
|
||||
if (This->interlace)
|
||||
{
|
||||
/* libpng requires us to write all data multiple times in this case. */
|
||||
This->stride = (This->format->bpp * This->width + 7)/8;
|
||||
This->data = HeapAlloc(GetProcessHeap(), 0, This->height * This->stride);
|
||||
if (!This->data)
|
||||
{
|
||||
LeaveCriticalSection(&This->lock);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
ppng_set_IHDR(This->png_ptr, This->info_ptr, This->width, This->height,
|
||||
This->format->bit_depth, This->format->color_type, PNG_INTERLACE_NONE,
|
||||
This->format->bit_depth, This->format->color_type,
|
||||
This->interlace ? PNG_INTERLACE_ADAM7 : PNG_INTERLACE_NONE,
|
||||
PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
|
||||
|
||||
if (This->xres != 0.0 && This->yres != 0.0)
|
||||
@@ -1257,9 +1304,26 @@ static HRESULT WINAPI PngFrameEncode_WritePixels(IWICBitmapFrameEncode *iface,
|
||||
if (This->format->swap_rgb)
|
||||
ppng_set_bgr(This->png_ptr);
|
||||
|
||||
if (This->interlace)
|
||||
This->passes = ppng_set_interlace_handling(This->png_ptr);
|
||||
|
||||
This->info_written = TRUE;
|
||||
}
|
||||
|
||||
if (This->interlace)
|
||||
{
|
||||
/* Just store the data so we can write it in multiple passes in Commit. */
|
||||
for (i=0; i<lineCount; i++)
|
||||
memcpy(This->data + This->stride * (This->lines_written + i),
|
||||
pbPixels + cbStride * i,
|
||||
This->stride);
|
||||
|
||||
This->lines_written += lineCount;
|
||||
|
||||
LeaveCriticalSection(&This->lock);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
row_pointers = HeapAlloc(GetProcessHeap(), 0, lineCount * sizeof(png_byte*));
|
||||
if (!row_pointers)
|
||||
{
|
||||
@@ -1285,77 +1349,28 @@ static HRESULT WINAPI PngFrameEncode_WriteSource(IWICBitmapFrameEncode *iface,
|
||||
{
|
||||
PngEncoder *This = impl_from_IWICBitmapFrameEncode(iface);
|
||||
HRESULT hr;
|
||||
WICRect rc;
|
||||
WICPixelFormatGUID guid;
|
||||
UINT stride;
|
||||
BYTE *pixeldata;
|
||||
TRACE("(%p,%p,%p)\n", iface, pIBitmapSource, prc);
|
||||
|
||||
if (!This->frame_initialized || !This->width || !This->height)
|
||||
if (!This->frame_initialized)
|
||||
return WINCODEC_ERR_WRONGSTATE;
|
||||
|
||||
if (!This->format)
|
||||
{
|
||||
hr = IWICBitmapSource_GetPixelFormat(pIBitmapSource, &guid);
|
||||
if (FAILED(hr)) return hr;
|
||||
hr = IWICBitmapFrameEncode_SetPixelFormat(iface, &guid);
|
||||
if (FAILED(hr)) return hr;
|
||||
}
|
||||
|
||||
hr = IWICBitmapSource_GetPixelFormat(pIBitmapSource, &guid);
|
||||
if (FAILED(hr)) return hr;
|
||||
if (memcmp(&guid, This->format->guid, sizeof(GUID)) != 0)
|
||||
{
|
||||
/* FIXME: should use WICConvertBitmapSource to convert */
|
||||
ERR("format %s unsupported\n", debugstr_guid(&guid));
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if (This->xres == 0.0 || This->yres == 0.0)
|
||||
{
|
||||
double xres, yres;
|
||||
hr = IWICBitmapSource_GetResolution(pIBitmapSource, &xres, &yres);
|
||||
if (FAILED(hr)) return hr;
|
||||
hr = IWICBitmapFrameEncode_SetResolution(iface, xres, yres);
|
||||
if (FAILED(hr)) return hr;
|
||||
}
|
||||
|
||||
if (!prc)
|
||||
{
|
||||
UINT width, height;
|
||||
hr = IWICBitmapSource_GetSize(pIBitmapSource, &width, &height);
|
||||
if (FAILED(hr)) return hr;
|
||||
rc.X = 0;
|
||||
rc.Y = 0;
|
||||
rc.Width = width;
|
||||
rc.Height = height;
|
||||
prc = &rc;
|
||||
}
|
||||
|
||||
if (prc->Width != This->width) return E_INVALIDARG;
|
||||
|
||||
stride = (This->format->bpp * This->width + 7)/8;
|
||||
|
||||
pixeldata = HeapAlloc(GetProcessHeap(), 0, stride * prc->Height);
|
||||
if (!pixeldata) return E_OUTOFMEMORY;
|
||||
|
||||
hr = IWICBitmapSource_CopyPixels(pIBitmapSource, prc, stride,
|
||||
stride*prc->Height, pixeldata);
|
||||
hr = configure_write_source(iface, pIBitmapSource, prc,
|
||||
This->format ? This->format->guid : NULL, This->width, This->height,
|
||||
This->xres, This->yres);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = IWICBitmapFrameEncode_WritePixels(iface, prc->Height, stride,
|
||||
stride*prc->Height, pixeldata);
|
||||
hr = write_source(iface, pIBitmapSource, prc,
|
||||
This->format->guid, This->format->bpp, This->width, This->height);
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, pixeldata);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI PngFrameEncode_Commit(IWICBitmapFrameEncode *iface)
|
||||
{
|
||||
PngEncoder *This = impl_from_IWICBitmapFrameEncode(iface);
|
||||
png_byte **row_pointers=NULL;
|
||||
jmp_buf jmpbuf;
|
||||
TRACE("(%p)\n", iface);
|
||||
|
||||
@@ -1371,14 +1386,35 @@ static HRESULT WINAPI PngFrameEncode_Commit(IWICBitmapFrameEncode *iface)
|
||||
if (setjmp(jmpbuf))
|
||||
{
|
||||
LeaveCriticalSection(&This->lock);
|
||||
HeapFree(GetProcessHeap(), 0, row_pointers);
|
||||
return E_FAIL;
|
||||
}
|
||||
ppng_set_error_fn(This->png_ptr, jmpbuf, user_error_fn, user_warning_fn);
|
||||
|
||||
if (This->interlace)
|
||||
{
|
||||
int i;
|
||||
|
||||
row_pointers = HeapAlloc(GetProcessHeap(), 0, This->height * sizeof(png_byte*));
|
||||
if (!row_pointers)
|
||||
{
|
||||
LeaveCriticalSection(&This->lock);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
for (i=0; i<This->height; i++)
|
||||
row_pointers[i] = This->data + This->stride * i;
|
||||
|
||||
for (i=0; i<This->passes; i++)
|
||||
ppng_write_rows(This->png_ptr, row_pointers, This->height);
|
||||
}
|
||||
|
||||
ppng_write_end(This->png_ptr, This->info_ptr);
|
||||
|
||||
This->frame_committed = TRUE;
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, row_pointers);
|
||||
|
||||
LeaveCriticalSection(&This->lock);
|
||||
|
||||
return S_OK;
|
||||
@@ -1456,6 +1492,7 @@ static ULONG WINAPI PngEncoder_Release(IWICBitmapEncoder *iface)
|
||||
ppng_destroy_write_struct(&This->png_ptr, &This->info_ptr);
|
||||
if (This->stream)
|
||||
IStream_Release(This->stream);
|
||||
HeapFree(GetProcessHeap(), 0, This->data);
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
}
|
||||
|
||||
@@ -1579,6 +1616,8 @@ static HRESULT WINAPI PngEncoder_CreateNewFrame(IWICBitmapEncoder *iface,
|
||||
{
|
||||
PngEncoder *This = impl_from_IWICBitmapEncoder(iface);
|
||||
HRESULT hr;
|
||||
PROPBAG2 opts[1]= {{0}};
|
||||
|
||||
TRACE("(%p,%p,%p)\n", iface, ppIFrameEncode, ppIEncoderOptions);
|
||||
|
||||
EnterCriticalSection(&This->lock);
|
||||
@@ -1595,7 +1634,11 @@ static HRESULT WINAPI PngEncoder_CreateNewFrame(IWICBitmapEncoder *iface,
|
||||
return WINCODEC_ERR_NOTINITIALIZED;
|
||||
}
|
||||
|
||||
hr = CreatePropertyBag2(NULL, 0, ppIEncoderOptions);
|
||||
opts[0].pstrName = (LPOLESTR)wszPngInterlaceOption;
|
||||
opts[0].vt = VT_BOOL;
|
||||
opts[0].dwType = PROPBAG2_TYPE_DATA;
|
||||
|
||||
hr = CreatePropertyBag2(opts, 1, ppIEncoderOptions);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
LeaveCriticalSection(&This->lock);
|
||||
@@ -1690,6 +1733,7 @@ HRESULT PngEncoder_CreateInstance(REFIID iid, void** ppv)
|
||||
This->lines_written = 0;
|
||||
This->frame_committed = FALSE;
|
||||
This->committed = FALSE;
|
||||
This->data = NULL;
|
||||
InitializeCriticalSection(&This->lock);
|
||||
This->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": PngEncoder.lock");
|
||||
|
||||
|
||||
@@ -232,7 +232,7 @@ static HRESULT WINAPI PropertyBag_GetPropertyInfo(IPropertyBag2 *iface, ULONG iP
|
||||
if (iProperty+cProperties > This->prop_count )
|
||||
return WINCODEC_ERR_VALUEOUTOFRANGE;
|
||||
|
||||
*pcProperties = max(cProperties, This->prop_count-iProperty);
|
||||
*pcProperties = min(cProperties, This->prop_count-iProperty);
|
||||
|
||||
for (i=0; i < *pcProperties; i++)
|
||||
{
|
||||
|
||||
@@ -208,6 +208,9 @@ HRESULT WINAPI IWICBitmapFrameEncode_SetThumbnail_Proxy_W(IWICBitmapFrameEncode
|
||||
HRESULT WINAPI IWICBitmapFrameEncode_WriteSource_Proxy_W(IWICBitmapFrameEncode *iface,
|
||||
IWICBitmapSource *pIBitmapSource, WICRect *prc)
|
||||
{
|
||||
if (prc && (prc->Width <= 0 || prc->Height <= 0))
|
||||
prc = NULL;
|
||||
|
||||
return IWICBitmapFrameEncode_WriteSource(iface, pIBitmapSource, prc);
|
||||
}
|
||||
|
||||
|
||||
@@ -1636,73 +1636,23 @@ static HRESULT WINAPI TiffFrameEncode_WriteSource(IWICBitmapFrameEncode *iface,
|
||||
{
|
||||
TiffFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
|
||||
HRESULT hr;
|
||||
WICRect rc;
|
||||
WICPixelFormatGUID guid;
|
||||
UINT stride;
|
||||
BYTE *pixeldata;
|
||||
|
||||
TRACE("(%p,%p,%p)\n", iface, pIBitmapSource, prc);
|
||||
|
||||
if (!This->initialized || !This->width || !This->height)
|
||||
if (!This->initialized)
|
||||
return WINCODEC_ERR_WRONGSTATE;
|
||||
|
||||
if (!This->format)
|
||||
{
|
||||
hr = IWICBitmapSource_GetPixelFormat(pIBitmapSource, &guid);
|
||||
if (FAILED(hr)) return hr;
|
||||
hr = IWICBitmapFrameEncode_SetPixelFormat(iface, &guid);
|
||||
if (FAILED(hr)) return hr;
|
||||
}
|
||||
|
||||
hr = IWICBitmapSource_GetPixelFormat(pIBitmapSource, &guid);
|
||||
if (FAILED(hr)) return hr;
|
||||
if (memcmp(&guid, This->format->guid, sizeof(GUID)) != 0)
|
||||
{
|
||||
/* FIXME: should use WICConvertBitmapSource to convert */
|
||||
ERR("format %s unsupported\n", debugstr_guid(&guid));
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if (This->xres == 0.0 || This->yres == 0.0)
|
||||
{
|
||||
double xres, yres;
|
||||
hr = IWICBitmapSource_GetResolution(pIBitmapSource, &xres, &yres);
|
||||
if (FAILED(hr)) return hr;
|
||||
hr = IWICBitmapFrameEncode_SetResolution(iface, xres, yres);
|
||||
if (FAILED(hr)) return hr;
|
||||
}
|
||||
|
||||
if (!prc)
|
||||
{
|
||||
UINT width, height;
|
||||
hr = IWICBitmapSource_GetSize(pIBitmapSource, &width, &height);
|
||||
if (FAILED(hr)) return hr;
|
||||
rc.X = 0;
|
||||
rc.Y = 0;
|
||||
rc.Width = width;
|
||||
rc.Height = height;
|
||||
prc = &rc;
|
||||
}
|
||||
|
||||
if (prc->Width != This->width) return E_INVALIDARG;
|
||||
|
||||
stride = (This->format->bpp * This->width + 7)/8;
|
||||
|
||||
pixeldata = HeapAlloc(GetProcessHeap(), 0, stride * prc->Height);
|
||||
if (!pixeldata) return E_OUTOFMEMORY;
|
||||
|
||||
hr = IWICBitmapSource_CopyPixels(pIBitmapSource, prc, stride,
|
||||
stride*prc->Height, pixeldata);
|
||||
hr = configure_write_source(iface, pIBitmapSource, prc,
|
||||
This->format ? This->format->guid : NULL, This->width, This->height,
|
||||
This->xres, This->yres);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = IWICBitmapFrameEncode_WritePixels(iface, prc->Height, stride,
|
||||
stride*prc->Height, pixeldata);
|
||||
hr = write_source(iface, pIBitmapSource, prc,
|
||||
This->format->guid, This->format->bpp, This->width, This->height);
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, pixeldata);
|
||||
|
||||
return S_OK;
|
||||
return hr;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI TiffFrameEncode_Commit(IWICBitmapFrameEncode *iface)
|
||||
|
||||
@@ -60,6 +60,7 @@ typedef void (__cdecl typeof(png_set_bgr))(struct png_struct_def *);
|
||||
typedef void (__cdecl typeof(png_set_error_fn))(struct png_struct_def *, void *, png_error_ptr_1, png_error_ptr_1);
|
||||
typedef void (__cdecl typeof(png_set_expand_gray_1_2_4_to_8))(struct png_struct_def *);
|
||||
typedef void (__cdecl typeof(png_set_filler))(struct png_struct_def *, unsigned int, int);
|
||||
typedef int (__cdecl typeof(png_set_interlace_handling))(struct png_struct_def *);
|
||||
typedef void (__cdecl typeof(png_set_gray_to_rgb))(struct png_struct_def *);
|
||||
typedef void (__cdecl typeof(png_set_IHDR))(struct png_struct_def *, struct png_info_def *, unsigned int, unsigned int, int, int, int, int, int);
|
||||
typedef void (__cdecl typeof(png_set_pHYs))(struct png_struct_def *, struct png_info_def *, unsigned int, unsigned int, int);
|
||||
|
||||
@@ -405,10 +405,7 @@ DGifGetImageDesc(GifFileType * GifFile) {
|
||||
GifFile->Image.Interlace = (Buf[0] & 0x40);
|
||||
if (Buf[0] & 0x80) { /* Does this image have local color map? */
|
||||
|
||||
/*** FIXME: Why do we check both of these in order to do this?
|
||||
* Why do we have both Image and SavedImages? */
|
||||
if (GifFile->Image.ColorMap && GifFile->SavedImages == NULL)
|
||||
FreeMapObject(GifFile->Image.ColorMap);
|
||||
FreeMapObject(GifFile->Image.ColorMap);
|
||||
|
||||
GifFile->Image.ColorMap = MakeMapObject(1 << BitsPerPixel, NULL);
|
||||
if (GifFile->Image.ColorMap == NULL) {
|
||||
|
||||
@@ -126,6 +126,16 @@ extern HRESULT copy_pixels(UINT bpp, const BYTE *srcbuffer,
|
||||
UINT srcwidth, UINT srcheight, INT srcstride,
|
||||
const WICRect *rc, UINT dststride, UINT dstbuffersize, BYTE *dstbuffer) DECLSPEC_HIDDEN;
|
||||
|
||||
extern HRESULT configure_write_source(IWICBitmapFrameEncode *iface,
|
||||
IWICBitmapSource *source, const WICRect *prc,
|
||||
const WICPixelFormatGUID *format,
|
||||
INT width, INT height, double xres, double yres) DECLSPEC_HIDDEN;
|
||||
|
||||
extern HRESULT write_source(IWICBitmapFrameEncode *iface,
|
||||
IWICBitmapSource *source, const WICRect *prc,
|
||||
const WICPixelFormatGUID *format, UINT bpp,
|
||||
INT width, INT height) DECLSPEC_HIDDEN;
|
||||
|
||||
extern void reverse_bgr8(UINT bytesperpixel, LPBYTE bits, UINT width, UINT height, INT stride) DECLSPEC_HIDDEN;
|
||||
|
||||
extern HRESULT get_pixelformat_bpp(const GUID *pixelformat, UINT *bpp) DECLSPEC_HIDDEN;
|
||||
|
||||
@@ -208,7 +208,7 @@ reactos/dll/win32/version # Synced to Wine-1.7.17
|
||||
reactos/dll/win32/wbemdisp # Synced to Wine-1.7.17
|
||||
reactos/dll/win32/wbemprox # Synced to Wine-1.7.27
|
||||
reactos/dll/win32/wer # Autosync
|
||||
reactos/dll/win32/windowscodecs # Synced to Wine-1.7.17
|
||||
reactos/dll/win32/windowscodecs # Synced to Wine-1.7.27
|
||||
reactos/dll/win32/windowscodecsext # Synced to Wine-1.7.17
|
||||
reactos/dll/win32/winemp3.acm # Synced to Wine-1.7.17
|
||||
reactos/dll/win32/wing32 # Out of sync
|
||||
|
||||
Reference in New Issue
Block a user