From c4bb6449ee242f185a7d0db3cd11582ae2cf26f8 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Fri, 11 Dec 2009 17:16:21 -0600 Subject: [PATCH 5/6] gdiplus: Initialize the palettes of new indexed bitmaps. --- dlls/gdiplus/image.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 68 insertions(+), 0 deletions(-) diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c index 982956c..f78b70a 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; } -- 1.6.3.3