Vincent Povirk : windowscodecs: Implement CopyPalette for the GIF decoder.
Alexandre Julliard
julliard at winehq.org
Tue Aug 18 10:02:18 CDT 2009
Module: wine
Branch: master
Commit: 548cd05ceb018314228a60d384e461cca6b02d26
URL: http://source.winehq.org/git/wine.git/?a=commit;h=548cd05ceb018314228a60d384e461cca6b02d26
Author: Vincent Povirk <vincent at codeweavers.com>
Date: Mon Aug 17 10:56:34 2009 -0500
windowscodecs: Implement CopyPalette for the GIF decoder.
---
dlls/windowscodecs/gifformat.c | 39 +++++++++++++++++++++++++++++++++++++--
1 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/dlls/windowscodecs/gifformat.c b/dlls/windowscodecs/gifformat.c
index a900043..9423ec3 100644
--- a/dlls/windowscodecs/gifformat.c
+++ b/dlls/windowscodecs/gifformat.c
@@ -129,8 +129,43 @@ static HRESULT WINAPI GifFrameDecode_GetResolution(IWICBitmapFrameDecode *iface,
static HRESULT WINAPI GifFrameDecode_CopyPalette(IWICBitmapFrameDecode *iface,
IWICPalette *pIPalette)
{
- FIXME("(%p,%p): stub\n", iface, pIPalette);
- return E_NOTIMPL;
+ GifFrameDecode *This = (GifFrameDecode*)iface;
+ WICColor colors[256];
+ ColorMapObject *cm = This->frame->ImageDesc.ColorMap;
+ int i, trans;
+ ExtensionBlock *eb;
+ TRACE("(%p,%p)\n", iface, pIPalette);
+
+ if (!cm) cm = This->parent->gif->SColorMap;
+
+ if (cm->ColorCount > 256)
+ {
+ ERR("GIF contains %i colors???\n", cm->ColorCount);
+ return E_FAIL;
+ }
+
+ for (i = 0; i < cm->ColorCount; i++) {
+ colors[i] = 0xff000000| /* alpha */
+ cm->Colors[i].Red << 16|
+ cm->Colors[i].Green << 8|
+ cm->Colors[i].Blue;
+ }
+
+ /* look for the transparent color extension */
+ for (i = 0; i < This->frame->ExtensionBlockCount; ++i) {
+ eb = This->frame->ExtensionBlocks + i;
+ if (eb->Function == 0xF9 && eb->ByteCount == 4) {
+ if ((eb->Bytes[0] & 1) == 1) {
+ trans = (unsigned char)eb->Bytes[3];
+ colors[trans] &= 0xffffff; /* set alpha to 0 */
+ break;
+ }
+ }
+ }
+
+ IWICPalette_InitializeCustom(pIPalette, colors, cm->ColorCount);
+
+ return S_OK;
}
static HRESULT WINAPI GifFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface,
More information about the wine-cvs
mailing list