mirror of
https://github.com/reactos/wine.git
synced 2024-11-29 06:30:37 +00:00
windowscodecs: Implement TiffFrameDecode_WriteSource.
This commit is contained in:
parent
518f4fd6de
commit
75a010581a
@ -1440,8 +1440,75 @@ static HRESULT WINAPI TiffFrameEncode_WritePixels(IWICBitmapFrameEncode *iface,
|
||||
static HRESULT WINAPI TiffFrameEncode_WriteSource(IWICBitmapFrameEncode *iface,
|
||||
IWICBitmapSource *pIBitmapSource, WICRect *prc)
|
||||
{
|
||||
FIXME("(%p,%p,%p): stub\n", iface, pIBitmapSource, prc);
|
||||
return E_NOTIMPL;
|
||||
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)
|
||||
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);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = IWICBitmapFrameEncode_WritePixels(iface, prc->Height, stride,
|
||||
stride*prc->Height, pixeldata);
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, pixeldata);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI TiffFrameEncode_Commit(IWICBitmapFrameEncode *iface)
|
||||
|
Loading…
Reference in New Issue
Block a user