windowscodecs: Implement conversion from 48bppRGB to 32bppBGRA.
This commit is contained in:
parent
363a0fdda9
commit
7f73787947
|
@ -49,7 +49,8 @@ enum pixelformat {
|
||||||
format_16bppBGR565,
|
format_16bppBGR565,
|
||||||
format_24bppBGR,
|
format_24bppBGR,
|
||||||
format_32bppBGR,
|
format_32bppBGR,
|
||||||
format_32bppBGRA
|
format_32bppBGRA,
|
||||||
|
format_48bppRGB,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef HRESULT (*copyfunc)(struct FormatConverter *This, const WICRect *prc,
|
typedef HRESULT (*copyfunc)(struct FormatConverter *This, const WICRect *prc,
|
||||||
|
@ -581,6 +582,50 @@ static HRESULT copypixels_to_32bppBGRA(struct FormatConverter *This, const WICRe
|
||||||
if (prc)
|
if (prc)
|
||||||
return IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer);
|
return IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
case format_48bppRGB:
|
||||||
|
if (prc)
|
||||||
|
{
|
||||||
|
HRESULT res;
|
||||||
|
UINT x, y;
|
||||||
|
BYTE *srcdata;
|
||||||
|
UINT srcstride, srcdatasize;
|
||||||
|
const BYTE *srcrow;
|
||||||
|
const BYTE *srcpixel;
|
||||||
|
BYTE *dstrow;
|
||||||
|
DWORD *dstpixel;
|
||||||
|
|
||||||
|
srcstride = 6 * prc->Width;
|
||||||
|
srcdatasize = srcstride * prc->Height;
|
||||||
|
|
||||||
|
srcdata = HeapAlloc(GetProcessHeap(), 0, srcdatasize);
|
||||||
|
if (!srcdata) return E_OUTOFMEMORY;
|
||||||
|
|
||||||
|
res = IWICBitmapSource_CopyPixels(This->source, prc, srcstride, srcdatasize, srcdata);
|
||||||
|
|
||||||
|
if (SUCCEEDED(res))
|
||||||
|
{
|
||||||
|
srcrow = srcdata;
|
||||||
|
dstrow = pbBuffer;
|
||||||
|
for (y=0; y<prc->Height; y++) {
|
||||||
|
srcpixel=srcrow;
|
||||||
|
dstpixel=(DWORD*)dstrow;
|
||||||
|
for (x=0; x<prc->Width; x++) {
|
||||||
|
BYTE red, green, blue;
|
||||||
|
red = *srcpixel++; srcpixel++;
|
||||||
|
green = *srcpixel++; srcpixel++;
|
||||||
|
blue = *srcpixel++; srcpixel++;
|
||||||
|
*dstpixel++=0xff000000|red<<16|green<<8|blue;
|
||||||
|
}
|
||||||
|
srcrow += srcstride;
|
||||||
|
dstrow += cbStride;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(), 0, srcdata);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
return S_OK;
|
||||||
default:
|
default:
|
||||||
return WINCODEC_ERR_UNSUPPORTEDOPERATION;
|
return WINCODEC_ERR_UNSUPPORTEDOPERATION;
|
||||||
}
|
}
|
||||||
|
@ -616,6 +661,7 @@ static const struct pixelformatinfo supported_formats[] = {
|
||||||
{format_24bppBGR, &GUID_WICPixelFormat24bppBGR, NULL},
|
{format_24bppBGR, &GUID_WICPixelFormat24bppBGR, NULL},
|
||||||
{format_32bppBGR, &GUID_WICPixelFormat32bppBGR, copypixels_to_32bppBGR},
|
{format_32bppBGR, &GUID_WICPixelFormat32bppBGR, copypixels_to_32bppBGR},
|
||||||
{format_32bppBGRA, &GUID_WICPixelFormat32bppBGRA, copypixels_to_32bppBGRA},
|
{format_32bppBGRA, &GUID_WICPixelFormat32bppBGRA, copypixels_to_32bppBGRA},
|
||||||
|
{format_48bppRGB, &GUID_WICPixelFormat48bppRGB, NULL},
|
||||||
{0}
|
{0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -931,6 +931,7 @@ static GUID const * const converter_formats[] = {
|
||||||
&GUID_WICPixelFormat24bppBGR,
|
&GUID_WICPixelFormat24bppBGR,
|
||||||
&GUID_WICPixelFormat32bppBGR,
|
&GUID_WICPixelFormat32bppBGR,
|
||||||
&GUID_WICPixelFormat32bppBGRA,
|
&GUID_WICPixelFormat32bppBGRA,
|
||||||
|
&GUID_WICPixelFormat48bppRGB,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue