gdiplus: Use the given HPALETTE in GdipCreateBitmapFromHBITMAP.

This commit is contained in:
Vincent Povirk 2011-03-28 16:03:29 -05:00 committed by Alexandre Julliard
parent 57d70bfdda
commit a7444e8e2c
2 changed files with 52 additions and 10 deletions

View File

@ -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;

View File

@ -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);