Vincent Povirk : windowscodecs: Implement conversion from 4bppIndexed to 32bppBGRA.
Alexandre Julliard
julliard at winehq.org
Fri Aug 14 08:59:56 CDT 2009
Module: wine
Branch: master
Commit: 9c1db8d82810389a33462cc535ccf4374c4e3bbe
URL: http://source.winehq.org/git/wine.git/?a=commit;h=9c1db8d82810389a33462cc535ccf4374c4e3bbe
Author: Vincent Povirk <vincent at codeweavers.com>
Date: Thu Aug 13 14:01:39 2009 -0500
windowscodecs: Implement conversion from 4bppIndexed to 32bppBGRA.
---
dlls/windowscodecs/converter.c | 59 ++++++++++++++++++++++++++++++++++++++++
dlls/windowscodecs/regsvr.c | 1 +
2 files changed, 60 insertions(+), 0 deletions(-)
diff --git a/dlls/windowscodecs/converter.c b/dlls/windowscodecs/converter.c
index 8e98bc6..a564fcb 100644
--- a/dlls/windowscodecs/converter.c
+++ b/dlls/windowscodecs/converter.c
@@ -37,6 +37,7 @@ struct FormatConverter;
enum pixelformat {
format_1bppIndexed,
+ format_4bppIndexed,
format_16bppBGR555,
format_16bppBGR565,
format_24bppBGR,
@@ -131,6 +132,63 @@ static HRESULT copypixels_to_32bppBGRA(struct FormatConverter *This, const WICRe
return res;
}
return S_OK;
+ case format_4bppIndexed:
+ if (prc)
+ {
+ HRESULT res;
+ UINT x, y;
+ BYTE *srcdata;
+ UINT srcstride, srcdatasize;
+ const BYTE *srcrow;
+ const BYTE *srcbyte;
+ BYTE *dstrow;
+ DWORD *dstpixel;
+ WICColor colors[16];
+ IWICPalette *palette;
+ UINT actualcolors;
+
+ res = PaletteImpl_Create(&palette);
+ if (FAILED(res)) return res;
+
+ res = IWICBitmapSource_CopyPalette(This->source, palette);
+ if (SUCCEEDED(res))
+ res = IWICPalette_GetColors(palette, 16, colors, &actualcolors);
+
+ IWICPalette_Release(palette);
+
+ if (FAILED(res)) return res;
+
+ srcstride = (prc->Width+1)/2;
+ 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++) {
+ srcbyte=(const BYTE*)srcrow;
+ dstpixel=(DWORD*)dstrow;
+ for (x=0; x<prc->Width; x+=2) {
+ BYTE srcval;
+ srcval=*srcbyte++;
+ *dstpixel++ = colors[srcval>>4];
+ if (x+1 < prc->Width) *dstpixel++ = colors[srcval&0xf];
+ }
+ srcrow += srcstride;
+ dstrow += cbStride;
+ }
+ }
+
+ HeapFree(GetProcessHeap(), 0, srcdata);
+
+ return res;
+ }
+ return S_OK;
case format_16bppBGR555:
if (prc)
{
@@ -311,6 +369,7 @@ static HRESULT copypixels_to_32bppBGR(struct FormatConverter *This, const WICRec
static const struct pixelformatinfo supported_formats[] = {
{format_1bppIndexed, &GUID_WICPixelFormat1bppIndexed, NULL},
+ {format_4bppIndexed, &GUID_WICPixelFormat4bppIndexed, NULL},
{format_16bppBGR555, &GUID_WICPixelFormat16bppBGR555, NULL},
{format_16bppBGR565, &GUID_WICPixelFormat16bppBGR565, NULL},
{format_24bppBGR, &GUID_WICPixelFormat24bppBGR, NULL},
diff --git a/dlls/windowscodecs/regsvr.c b/dlls/windowscodecs/regsvr.c
index 7c7d2cf..a95274e 100644
--- a/dlls/windowscodecs/regsvr.c
+++ b/dlls/windowscodecs/regsvr.c
@@ -790,6 +790,7 @@ static struct regsvr_decoder const decoder_list[] = {
static GUID const * const converter_formats[] = {
&GUID_WICPixelFormat1bppIndexed,
+ &GUID_WICPixelFormat4bppIndexed,
&GUID_WICPixelFormat16bppBGR555,
&GUID_WICPixelFormat16bppBGR565,
&GUID_WICPixelFormat24bppBGR,
More information about the wine-cvs
mailing list