diff options
Diffstat (limited to 'win/tkWinImage.c')
-rw-r--r-- | win/tkWinImage.c | 29 |
1 files changed, 28 insertions, 1 deletions
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; |