From cb79033c9b3014af425e76408eca6cea98376986 Mon Sep 17 00:00:00 2001 From: hobbs Date: Tue, 28 Oct 2003 22:52:01 +0000 Subject: * win/tkWinImage.c (XGetImageZPixmap): add separate 16bpp XGetImage code to correctly handle 16bpp requests. This appears to never have worked correctly. --- win/tkWinImage.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/win/tkWinImage.c b/win/tkWinImage.c index 49e2d7a..70d937c 100644 --- a/win/tkWinImage.c +++ b/win/tkWinImage.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinImage.c,v 1.7 2003/07/17 01:02:32 hobbs Exp $ + * RCS: @(#) $Id: tkWinImage.c,v 1.8 2003/10/28 22:52:01 hobbs Exp $ */ #include "tkWinInt.h" @@ -425,6 +425,29 @@ XGetImageZPixmap(display, d, x, y, width, height, plane_mask, format) for (i = 0; i < bmInfo->bmiHeader.biSizeImage; i++, p++) { *p = (unsigned char) palette[*p]; } + } else if (depth == 16) { + GetDIBits(hdcMem, hbmp, 0, height, NULL, bmInfo, DIB_RGB_COLORS); + data = ckalloc(bmInfo->bmiHeader.biSizeImage); + if (!data) { + /* printf("Failed to allocate data area for XImage.\n"); */ + ret_image = NULL; + goto cleanup; + } + ret_image = XCreateImage(display, NULL, 16, ZPixmap, 0, data, + width, height, 16, 0 /* will be calc'ed from bitmap_pad */); + if (ret_image == NULL) { + ckfree((char *) data); + goto cleanup; + } + + /* Get the BITMAP info directly into the Image. */ + if (GetDIBits(hdcMem, hbmp, 0, height, ret_image->data, bmInfo, + DIB_RGB_COLORS) == 0) { + ckfree((char *) ret_image->data); + ckfree((char *) ret_image); + ret_image = NULL; + goto cleanup; + } } else { GetDIBits(hdcMem, hbmp, 0, height, NULL, bmInfo, DIB_RGB_COLORS); data = ckalloc(width * height * 4); @@ -441,6 +464,10 @@ XGetImageZPixmap(display, d, x, y, width, height, plane_mask, format) } if (depth <= 24) { + /* + * This used to handle 16 and 24 bpp, but now just handles 24. + * It can likely be optimized for that. -- hobbs + */ unsigned char *smallBitData, *smallBitBase, *bigBitData; unsigned int byte_width, h, w; -- cgit v0.12