Module: wine Branch: master Commit: 7f73787947aa03827d489884218f56d9992fb2c7 URL: http://source.winehq.org/git/wine.git/?a=commit;h=7f73787947aa03827d48988421...
Author: Vincent Povirk vincent@codeweavers.com Date: Thu Aug 27 13:37:25 2009 -0500
windowscodecs: Implement conversion from 48bppRGB to 32bppBGRA.
---
dlls/windowscodecs/converter.c | 48 +++++++++++++++++++++++++++++++++++++++- dlls/windowscodecs/regsvr.c | 1 + 2 files changed, 48 insertions(+), 1 deletions(-)
diff --git a/dlls/windowscodecs/converter.c b/dlls/windowscodecs/converter.c index 9351da4..61619dd 100644 --- a/dlls/windowscodecs/converter.c +++ b/dlls/windowscodecs/converter.c @@ -49,7 +49,8 @@ enum pixelformat { format_16bppBGR565, format_24bppBGR, format_32bppBGR, - format_32bppBGRA + format_32bppBGRA, + format_48bppRGB, };
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) return IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer); 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: return WINCODEC_ERR_UNSUPPORTEDOPERATION; } @@ -616,6 +661,7 @@ static const struct pixelformatinfo supported_formats[] = { {format_24bppBGR, &GUID_WICPixelFormat24bppBGR, NULL}, {format_32bppBGR, &GUID_WICPixelFormat32bppBGR, copypixels_to_32bppBGR}, {format_32bppBGRA, &GUID_WICPixelFormat32bppBGRA, copypixels_to_32bppBGRA}, + {format_48bppRGB, &GUID_WICPixelFormat48bppRGB, NULL}, {0} };
diff --git a/dlls/windowscodecs/regsvr.c b/dlls/windowscodecs/regsvr.c index 0a71048..865c7b7 100644 --- a/dlls/windowscodecs/regsvr.c +++ b/dlls/windowscodecs/regsvr.c @@ -931,6 +931,7 @@ static GUID const * const converter_formats[] = { &GUID_WICPixelFormat24bppBGR, &GUID_WICPixelFormat32bppBGR, &GUID_WICPixelFormat32bppBGRA, + &GUID_WICPixelFormat48bppRGB, NULL };