summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhobbs <hobbs@noemail.net>2003-10-28 22:52:00 (GMT)
committerhobbs <hobbs@noemail.net>2003-10-28 22:52:00 (GMT)
commitc67daac3d49178f7bd40754b78a3336a3bba5c69 (patch)
treefbacb95421f76e748ebd1bbd6bfcd44370754f46
parent53a329c18a9056e1b4fd2d90c55432b800f01f71 (diff)
downloadtk-c67daac3d49178f7bd40754b78a3336a3bba5c69.zip
tk-c67daac3d49178f7bd40754b78a3336a3bba5c69.tar.gz
tk-c67daac3d49178f7bd40754b78a3336a3bba5c69.tar.bz2
* win/tkWinImage.c (XGetImageZPixmap): add separate 16bpp
XGetImage code to correctly handle 16bpp requests. This appears to never have worked correctly. FossilOrigin-Name: d792c849c9791f0e7527e97b0ff6864a6859e918
-rw-r--r--win/tkWinImage.c29
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;