Commit a7444e8e authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

gdiplus: Use the given HPALETTE in GdipCreateBitmapFromHBITMAP.

parent 57d70bfd
......@@ -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;
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment