wincodecs: Trigger conversion to target format in WriteSource().
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Vincent Povirk <vincent@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
40a596fa86
commit
62830143d1
|
@ -122,30 +122,20 @@ HRESULT configure_write_source(IWICBitmapFrameEncode *iface,
|
||||||
const WICPixelFormatGUID *format,
|
const WICPixelFormatGUID *format,
|
||||||
INT width, INT height, double xres, double yres)
|
INT width, INT height, double xres, double yres)
|
||||||
{
|
{
|
||||||
HRESULT hr=S_OK;
|
HRESULT hr = S_OK;
|
||||||
WICPixelFormatGUID src_format, dst_format;
|
|
||||||
|
|
||||||
if (width == 0 || height == 0)
|
if (width == 0 || height == 0)
|
||||||
return WINCODEC_ERR_WRONGSTATE;
|
return WINCODEC_ERR_WRONGSTATE;
|
||||||
|
|
||||||
hr = IWICBitmapSource_GetPixelFormat(source, &src_format);
|
|
||||||
if (FAILED(hr)) return hr;
|
|
||||||
|
|
||||||
if (!format)
|
if (!format)
|
||||||
{
|
{
|
||||||
dst_format = src_format;
|
WICPixelFormatGUID src_format;
|
||||||
|
|
||||||
hr = IWICBitmapFrameEncode_SetPixelFormat(iface, &dst_format);
|
hr = IWICBitmapSource_GetPixelFormat(source, &src_format);
|
||||||
if (FAILED(hr)) return hr;
|
if (FAILED(hr)) return hr;
|
||||||
|
|
||||||
format = &dst_format;
|
hr = IWICBitmapFrameEncode_SetPixelFormat(iface, &src_format);
|
||||||
}
|
if (FAILED(hr)) return hr;
|
||||||
|
|
||||||
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)
|
if (xres == 0.0 || yres == 0.0)
|
||||||
|
@ -164,6 +154,7 @@ HRESULT write_source(IWICBitmapFrameEncode *iface,
|
||||||
const WICPixelFormatGUID *format, UINT bpp,
|
const WICPixelFormatGUID *format, UINT bpp,
|
||||||
INT width, INT height)
|
INT width, INT height)
|
||||||
{
|
{
|
||||||
|
IWICBitmapSource *converted_source;
|
||||||
HRESULT hr=S_OK;
|
HRESULT hr=S_OK;
|
||||||
WICRect rc;
|
WICRect rc;
|
||||||
UINT stride;
|
UINT stride;
|
||||||
|
@ -184,12 +175,23 @@ HRESULT write_source(IWICBitmapFrameEncode *iface,
|
||||||
if (prc->Width != width || prc->Height <= 0)
|
if (prc->Width != width || prc->Height <= 0)
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
|
|
||||||
|
hr = WICConvertBitmapSource(format, source, &converted_source);
|
||||||
|
if (FAILED(hr))
|
||||||
|
{
|
||||||
|
ERR("Failed to convert source, target format %s, %#x\n", debugstr_guid(format), hr);
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
stride = (bpp * width + 7)/8;
|
stride = (bpp * width + 7)/8;
|
||||||
|
|
||||||
pixeldata = HeapAlloc(GetProcessHeap(), 0, stride * prc->Height);
|
pixeldata = HeapAlloc(GetProcessHeap(), 0, stride * prc->Height);
|
||||||
if (!pixeldata) return E_OUTOFMEMORY;
|
if (!pixeldata)
|
||||||
|
{
|
||||||
|
IWICBitmapSource_Release(converted_source);
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
hr = IWICBitmapSource_CopyPixels(source, prc, stride,
|
hr = IWICBitmapSource_CopyPixels(converted_source, prc, stride,
|
||||||
stride*prc->Height, pixeldata);
|
stride*prc->Height, pixeldata);
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
|
@ -199,6 +201,7 @@ HRESULT write_source(IWICBitmapFrameEncode *iface,
|
||||||
}
|
}
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, pixeldata);
|
HeapFree(GetProcessHeap(), 0, pixeldata);
|
||||||
|
IWICBitmapSource_Release(converted_source);
|
||||||
|
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue