gdiplus: Always provide image data in the format requested by image encoders.
This commit is contained in:
parent
85b989c1fa
commit
12586f76e3
|
@ -4002,6 +4002,7 @@ static GpStatus encode_image_WIC(GpImage *image, IStream* stream,
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
UINT width, height;
|
UINT width, height;
|
||||||
PixelFormat gdipformat=0;
|
PixelFormat gdipformat=0;
|
||||||
|
const WICPixelFormatGUID *desired_wicformat;
|
||||||
WICPixelFormatGUID wicformat;
|
WICPixelFormatGUID wicformat;
|
||||||
GpRect rc;
|
GpRect rc;
|
||||||
BitmapData lockeddata;
|
BitmapData lockeddata;
|
||||||
|
@ -4054,20 +4055,40 @@ static GpStatus encode_image_WIC(GpImage *image, IStream* stream,
|
||||||
{
|
{
|
||||||
if (pixel_formats[i].gdip_format == bitmap->format)
|
if (pixel_formats[i].gdip_format == bitmap->format)
|
||||||
{
|
{
|
||||||
memcpy(&wicformat, pixel_formats[i].wic_format, sizeof(GUID));
|
desired_wicformat = pixel_formats[i].wic_format;
|
||||||
gdipformat = bitmap->format;
|
gdipformat = bitmap->format;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!gdipformat)
|
if (!gdipformat)
|
||||||
{
|
{
|
||||||
memcpy(&wicformat, &GUID_WICPixelFormat32bppBGRA, sizeof(GUID));
|
desired_wicformat = &GUID_WICPixelFormat32bppBGRA;
|
||||||
gdipformat = PixelFormat32bppARGB;
|
gdipformat = PixelFormat32bppARGB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memcpy(&wicformat, desired_wicformat, sizeof(GUID));
|
||||||
hr = IWICBitmapFrameEncode_SetPixelFormat(frameencode, &wicformat);
|
hr = IWICBitmapFrameEncode_SetPixelFormat(frameencode, &wicformat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SUCCEEDED(hr) && !IsEqualGUID(desired_wicformat, &wicformat))
|
||||||
|
{
|
||||||
|
/* Encoder doesn't support this bitmap's format. */
|
||||||
|
gdipformat = 0;
|
||||||
|
for (i=0; pixel_formats[i].wic_format; i++)
|
||||||
|
{
|
||||||
|
if (IsEqualGUID(&wicformat, pixel_formats[i].wic_format))
|
||||||
|
{
|
||||||
|
gdipformat = bitmap->format;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!gdipformat)
|
||||||
|
{
|
||||||
|
ERR("Cannot support encoder format %s\n", debugstr_guid(&wicformat));
|
||||||
|
hr = E_FAIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
stat = GdipBitmapLockBits(bitmap, &rc, ImageLockModeRead, gdipformat,
|
stat = GdipBitmapLockBits(bitmap, &rc, ImageLockModeRead, gdipformat,
|
||||||
|
|
Loading…
Reference in New Issue