diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c index 982956c4643..f78b70aa891 100644 --- a/dlls/gdiplus/image.c +++ b/dlls/gdiplus/image.c @@ -1134,6 +1134,44 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHICON(HICON hicon, GpBitmap** bitmap) return Ok; } +static void generate_halftone_palette(ARGB *entries, UINT count) +{ + static const BYTE halftone_values[6]={0x00,0x33,0x66,0x99,0xcc,0xff}; + UINT i; + + for (i=0; i<8 && ibits = bits; (*bitmap)->stride = dib_stride; + if (format == PixelFormat1bppIndexed || + format == PixelFormat4bppIndexed || + format == PixelFormat8bppIndexed) + { + (*bitmap)->image.palette_size = (*bitmap)->image.palette_count = 1 << PIXELFORMATBPP(format); + (*bitmap)->image.palette_entries = GdipAlloc(sizeof(ARGB) * ((*bitmap)->image.palette_size)); + + if (!(*bitmap)->image.palette_entries) + { + GdipDisposeImage(&(*bitmap)->image); + *bitmap = NULL; + return OutOfMemory; + } + + if (format == PixelFormat1bppIndexed) + { + (*bitmap)->image.palette_flags = PaletteFlagsGrayScale; + (*bitmap)->image.palette_entries[0] = 0xff000000; + (*bitmap)->image.palette_entries[1] = 0xffffffff; + } + else + { + if (format == PixelFormat8bppIndexed) + (*bitmap)->image.palette_flags = PaletteFlagsHalftone; + + generate_halftone_palette((*bitmap)->image.palette_entries, + (*bitmap)->image.palette_count); + } + } + return Ok; }