Vincent Povirk : gdiplus: Use the given HPALETTE in GdipCreateBitmapFromHBITMAP.
Alexandre Julliard
julliard at winehq.org
Tue Mar 29 11:43:03 CDT 2011
Module: wine
Branch: master
Commit: a7444e8e2c4dcccbfe621e8e6945cef989499d21
URL: http://source.winehq.org/git/wine.git/?a=commit;h=a7444e8e2c4dcccbfe621e8e6945cef989499d21
Author: Vincent Povirk <vincent at codeweavers.com>
Date: Mon Mar 28 16:03:29 2011 -0500
gdiplus: Use the given HPALETTE in GdipCreateBitmapFromHBITMAP.
---
dlls/gdiplus/image.c | 56 +++++++++++++++++++++++++++++++++++++++----
dlls/gdiplus/tests/image.c | 6 +---
2 files changed, 52 insertions(+), 10 deletions(-)
diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c
index 1916524..35ebd29 100644
--- a/dlls/gdiplus/image.c
+++ b/dlls/gdiplus/image.c
@@ -3524,12 +3524,6 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHBITMAP(HBITMAP hbm, HPALETTE hpal, GpBi
if(!hbm || !bitmap)
return InvalidParameter;
- /* TODO: Support for device-dependent bitmaps */
- if(hpal){
- FIXME("no support for device-dependent bitmaps\n");
- return NotImplemented;
- }
-
if (GetObjectA(hbm, sizeof(bm), &bm) != sizeof(bm))
return InvalidParameter;
@@ -3626,6 +3620,56 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHBITMAP(HBITMAP hbm, HPALETTE hpal, GpBi
GdipBitmapUnlockBits(*bitmap, &lockeddata);
}
+
+ if (retval == Ok && hpal)
+ {
+ WORD num_palette_entries;
+ PALETTEENTRY *palette_entries=NULL;
+ ColorPalette *palette=NULL;
+ int i;
+
+ if (!GetObjectW(hpal, sizeof(num_palette_entries), &num_palette_entries))
+ retval = GenericError;
+
+ if (retval == Ok)
+ {
+ palette_entries = GdipAlloc(sizeof(PALETTEENTRY) * num_palette_entries);
+ palette = GdipAlloc(sizeof(ColorPalette) + sizeof(ARGB) * (num_palette_entries-1));
+
+ if (!palette_entries || !palette)
+ retval = OutOfMemory;
+ }
+
+ if (retval == Ok)
+ {
+ if (!GetPaletteEntries(hpal, 0, num_palette_entries, palette_entries))
+ retval = GenericError;
+ }
+
+ if (retval == Ok)
+ {
+ palette->Flags = 0;
+ palette->Count = num_palette_entries;
+
+ for (i=0; i<num_palette_entries; i++)
+ {
+ PALETTEENTRY * entry = &palette_entries[i];
+ palette->Entries[i] = 0xff000000 | entry->peRed << 16 |
+ entry->peGreen << 8 | entry->peBlue;
+ }
+
+ retval = GdipSetImagePalette((GpImage*)*bitmap, palette);
+ }
+
+ GdipFree(palette_entries);
+ GdipFree(palette);
+ }
+
+ if (retval != Ok)
+ {
+ GdipDisposeImage((GpImage*)*bitmap);
+ *bitmap = NULL;
+ }
}
return retval;
diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c
index 1e6a9e9..77aec93 100644
--- a/dlls/gdiplus/tests/image.c
+++ b/dlls/gdiplus/tests/image.c
@@ -917,10 +917,8 @@ static void test_GdipCreateBitmapFromHBITMAP(void)
GdipFree(LogPal);
stat = GdipCreateBitmapFromHBITMAP(hbm, hpal, &gpbm);
- todo_wine
- {
- expect(Ok, stat);
- }
+ expect(Ok, stat);
+
if (stat == Ok)
GdipDisposeImage((GpImage*)gpbm);
More information about the wine-cvs
mailing list