windowscodecs: Share WriteSource code between implementations.
This commit is contained in:
parent
a270ed90ad
commit
30f9834061
@ -260,63 +260,22 @@ static HRESULT WINAPI BmpFrameEncode_WriteSource(IWICBitmapFrameEncode *iface,
|
|||||||
{
|
{
|
||||||
BmpFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
|
BmpFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
WICRect rc;
|
|
||||||
WICPixelFormatGUID guid;
|
|
||||||
TRACE("(%p,%p,%p)\n", iface, pIBitmapSource, prc);
|
TRACE("(%p,%p,%p)\n", iface, pIBitmapSource, prc);
|
||||||
|
|
||||||
if (!This->initialized || !This->width || !This->height)
|
if (!This->initialized)
|
||||||
return WINCODEC_ERR_WRONGSTATE;
|
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);
|
hr = write_source(iface, pIBitmapSource, prc,
|
||||||
if (FAILED(hr)) return hr;
|
This->format->guid, This->format->bpp, This->width, This->height);
|
||||||
hr = BmpFrameEncode_SetPixelFormat(iface, &guid);
|
|
||||||
if (FAILED(hr)) return hr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hr = IWICBitmapSource_GetPixelFormat(pIBitmapSource, &guid);
|
return hr;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI BmpFrameEncode_Commit(IWICBitmapFrameEncode *iface)
|
static HRESULT WINAPI BmpFrameEncode_Commit(IWICBitmapFrameEncode *iface)
|
||||||
|
@ -391,66 +391,22 @@ static HRESULT WINAPI IcnsFrameEncode_WriteSource(IWICBitmapFrameEncode *iface,
|
|||||||
{
|
{
|
||||||
IcnsFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
|
IcnsFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
WICRect rc;
|
|
||||||
WICPixelFormatGUID guid;
|
|
||||||
UINT stride;
|
|
||||||
BYTE *pixeldata = NULL;
|
|
||||||
|
|
||||||
TRACE("(%p,%p,%p)\n", iface, pIBitmapSource, prc);
|
TRACE("(%p,%p,%p)\n", iface, pIBitmapSource, prc);
|
||||||
|
|
||||||
if (!This->initialized || !This->size)
|
if (!This->initialized)
|
||||||
{
|
return WINCODEC_ERR_WRONGSTATE;
|
||||||
hr = WINCODEC_ERR_WRONGSTATE;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
hr = IWICBitmapSource_GetPixelFormat(pIBitmapSource, &guid);
|
hr = configure_write_source(iface, pIBitmapSource, &prc,
|
||||||
if (FAILED(hr))
|
&GUID_WICPixelFormat32bppBGRA, This->size, This->size,
|
||||||
goto end;
|
1.0, 1.0);
|
||||||
if (!IsEqualGUID(&guid, &GUID_WICPixelFormat32bppBGRA))
|
|
||||||
{
|
|
||||||
FIXME("format %s unsupported, could use WICConvertBitmapSource to convert\n", debugstr_guid(&guid));
|
|
||||||
hr = E_FAIL;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
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))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
hr = IWICBitmapFrameEncode_WritePixels(iface, prc->Height, stride,
|
hr = write_source(iface, pIBitmapSource, prc,
|
||||||
stride*prc->Height, pixeldata);
|
&GUID_WICPixelFormat32bppBGRA, 32, This->size, This->size);
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
|
||||||
HeapFree(GetProcessHeap(), 0, pixeldata);
|
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1107,71 +1107,21 @@ static HRESULT WINAPI JpegEncoder_Frame_WriteSource(IWICBitmapFrameEncode *iface
|
|||||||
{
|
{
|
||||||
JpegEncoder *This = impl_from_IWICBitmapFrameEncode(iface);
|
JpegEncoder *This = impl_from_IWICBitmapFrameEncode(iface);
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
WICRect rc;
|
|
||||||
WICPixelFormatGUID guid;
|
|
||||||
UINT stride;
|
|
||||||
BYTE *pixeldata;
|
|
||||||
TRACE("(%p,%p,%p)\n", iface, pIBitmapSource, prc);
|
TRACE("(%p,%p,%p)\n", iface, pIBitmapSource, prc);
|
||||||
|
|
||||||
if (!This->frame_initialized || !This->width || !This->height)
|
if (!This->frame_initialized)
|
||||||
return WINCODEC_ERR_WRONGSTATE;
|
return WINCODEC_ERR_WRONGSTATE;
|
||||||
|
|
||||||
if (!This->format)
|
hr = configure_write_source(iface, pIBitmapSource, prc,
|
||||||
{
|
This->format ? This->format->guid : NULL, This->width, This->height,
|
||||||
hr = IWICBitmapSource_GetPixelFormat(pIBitmapSource, &guid);
|
This->xres, This->yres);
|
||||||
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);
|
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
hr = IWICBitmapFrameEncode_WritePixels(iface, prc->Height, stride,
|
hr = write_source(iface, pIBitmapSource, prc,
|
||||||
stride*prc->Height, pixeldata);
|
This->format->guid, This->format->bpp, This->width, This->height);
|
||||||
}
|
}
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, pixeldata);
|
|
||||||
|
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,6 +118,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)
|
||||||
|
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)
|
void reverse_bgr8(UINT bytesperpixel, LPBYTE bits, UINT width, UINT height, INT stride)
|
||||||
{
|
{
|
||||||
UINT x, y;
|
UINT x, y;
|
||||||
|
@ -1304,71 +1304,21 @@ static HRESULT WINAPI PngFrameEncode_WriteSource(IWICBitmapFrameEncode *iface,
|
|||||||
{
|
{
|
||||||
PngEncoder *This = impl_from_IWICBitmapFrameEncode(iface);
|
PngEncoder *This = impl_from_IWICBitmapFrameEncode(iface);
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
WICRect rc;
|
|
||||||
WICPixelFormatGUID guid;
|
|
||||||
UINT stride;
|
|
||||||
BYTE *pixeldata;
|
|
||||||
TRACE("(%p,%p,%p)\n", iface, pIBitmapSource, prc);
|
TRACE("(%p,%p,%p)\n", iface, pIBitmapSource, prc);
|
||||||
|
|
||||||
if (!This->frame_initialized || !This->width || !This->height)
|
if (!This->frame_initialized)
|
||||||
return WINCODEC_ERR_WRONGSTATE;
|
return WINCODEC_ERR_WRONGSTATE;
|
||||||
|
|
||||||
if (!This->format)
|
hr = configure_write_source(iface, pIBitmapSource, prc,
|
||||||
{
|
This->format ? This->format->guid : NULL, This->width, This->height,
|
||||||
hr = IWICBitmapSource_GetPixelFormat(pIBitmapSource, &guid);
|
This->xres, This->yres);
|
||||||
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);
|
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
hr = IWICBitmapFrameEncode_WritePixels(iface, prc->Height, stride,
|
hr = write_source(iface, pIBitmapSource, prc,
|
||||||
stride*prc->Height, pixeldata);
|
This->format->guid, This->format->bpp, This->width, This->height);
|
||||||
}
|
}
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, pixeldata);
|
|
||||||
|
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1653,73 +1653,23 @@ static HRESULT WINAPI TiffFrameEncode_WriteSource(IWICBitmapFrameEncode *iface,
|
|||||||
{
|
{
|
||||||
TiffFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
|
TiffFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
WICRect rc;
|
|
||||||
WICPixelFormatGUID guid;
|
|
||||||
UINT stride;
|
|
||||||
BYTE *pixeldata;
|
|
||||||
|
|
||||||
TRACE("(%p,%p,%p)\n", iface, pIBitmapSource, prc);
|
TRACE("(%p,%p,%p)\n", iface, pIBitmapSource, prc);
|
||||||
|
|
||||||
if (!This->initialized || !This->width || !This->height)
|
if (!This->initialized)
|
||||||
return WINCODEC_ERR_WRONGSTATE;
|
return WINCODEC_ERR_WRONGSTATE;
|
||||||
|
|
||||||
if (!This->format)
|
hr = configure_write_source(iface, pIBitmapSource, prc,
|
||||||
{
|
This->format ? This->format->guid : NULL, This->width, This->height,
|
||||||
hr = IWICBitmapSource_GetPixelFormat(pIBitmapSource, &guid);
|
This->xres, This->yres);
|
||||||
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);
|
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
hr = IWICBitmapFrameEncode_WritePixels(iface, prc->Height, stride,
|
hr = write_source(iface, pIBitmapSource, prc,
|
||||||
stride*prc->Height, pixeldata);
|
This->format->guid, This->format->bpp, This->width, This->height);
|
||||||
}
|
}
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, pixeldata);
|
return hr;
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI TiffFrameEncode_Commit(IWICBitmapFrameEncode *iface)
|
static HRESULT WINAPI TiffFrameEncode_Commit(IWICBitmapFrameEncode *iface)
|
||||||
|
@ -99,6 +99,16 @@ extern HRESULT copy_pixels(UINT bpp, const BYTE *srcbuffer,
|
|||||||
UINT srcwidth, UINT srcheight, INT srcstride,
|
UINT srcwidth, UINT srcheight, INT srcstride,
|
||||||
const WICRect *rc, UINT dststride, UINT dstbuffersize, BYTE *dstbuffer) DECLSPEC_HIDDEN;
|
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 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;
|
extern HRESULT get_pixelformat_bpp(const GUID *pixelformat, UINT *bpp) DECLSPEC_HIDDEN;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user