Module: wine Branch: master Commit: 1a62109b70e0e6a61141f8269c77dd1129c2dc71 URL: http://source.winehq.org/git/wine.git/?a=commit;h=1a62109b70e0e6a61141f8269c...
Author: Vincent Povirk vincent@codeweavers.com Date: Thu Aug 13 13:56:02 2009 -0500
windowscodecs: Implement conversion from 24bppBGR to 32bppBGRA.
---
dlls/windowscodecs/converter.c | 45 ++++++++++++++++++++++++++++++++++++++++ dlls/windowscodecs/regsvr.c | 1 + 2 files changed, 46 insertions(+), 0 deletions(-)
diff --git a/dlls/windowscodecs/converter.c b/dlls/windowscodecs/converter.c index 7213151..8e98bc6 100644 --- a/dlls/windowscodecs/converter.c +++ b/dlls/windowscodecs/converter.c @@ -39,6 +39,7 @@ enum pixelformat { format_1bppIndexed, format_16bppBGR555, format_16bppBGR565, + format_24bppBGR, format_32bppBGR, format_32bppBGRA }; @@ -226,6 +227,49 @@ static HRESULT copypixels_to_32bppBGRA(struct FormatConverter *This, const WICRe return res; } return S_OK; + case format_24bppBGR: + if (prc) + { + HRESULT res; + UINT x, y; + BYTE *srcdata; + UINT srcstride, srcdatasize; + const BYTE *srcrow; + const BYTE *srcpixel; + BYTE *dstrow; + BYTE *dstpixel; + + srcstride = 3 * 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=dstrow; + for (x=0; x<prc->Width; x++) { + *dstpixel++=*srcpixel++; /* blue */ + *dstpixel++=*srcpixel++; /* green */ + *dstpixel++=*srcpixel++; /* red */ + *dstpixel++=255; /* alpha */ + } + srcrow += srcstride; + dstrow += cbStride; + } + } + + HeapFree(GetProcessHeap(), 0, srcdata); + + return res; + } + return S_OK; case format_32bppBGR: if (prc) { @@ -269,6 +313,7 @@ static const struct pixelformatinfo supported_formats[] = { {format_1bppIndexed, &GUID_WICPixelFormat1bppIndexed, NULL}, {format_16bppBGR555, &GUID_WICPixelFormat16bppBGR555, NULL}, {format_16bppBGR565, &GUID_WICPixelFormat16bppBGR565, NULL}, + {format_24bppBGR, &GUID_WICPixelFormat24bppBGR, NULL}, {format_32bppBGR, &GUID_WICPixelFormat32bppBGR, copypixels_to_32bppBGR}, {format_32bppBGRA, &GUID_WICPixelFormat32bppBGRA, copypixels_to_32bppBGRA}, {0} diff --git a/dlls/windowscodecs/regsvr.c b/dlls/windowscodecs/regsvr.c index b8280ac..7c7d2cf 100644 --- a/dlls/windowscodecs/regsvr.c +++ b/dlls/windowscodecs/regsvr.c @@ -792,6 +792,7 @@ static GUID const * const converter_formats[] = { &GUID_WICPixelFormat1bppIndexed, &GUID_WICPixelFormat16bppBGR555, &GUID_WICPixelFormat16bppBGR565, + &GUID_WICPixelFormat24bppBGR, &GUID_WICPixelFormat32bppBGR, &GUID_WICPixelFormat32bppBGRA, NULL