summaryrefslogtreecommitdiffstats
path: root/win/tkWinImage.c
diff options
context:
space:
mode:
authorhobbs <hobbs@noemail.net>2003-10-29 01:08:01 (GMT)
committerhobbs <hobbs@noemail.net>2003-10-29 01:08:01 (GMT)
commitfd047f8e97cc4473ffe22a68793b60992d8081a8 (patch)
treebb771657b97f1054543f81a04bf4a6b18b6e8f4b /win/tkWinImage.c
parent9aec3ff9564da1587ebcc93937f847a056f2be7c (diff)
downloadtk-fd047f8e97cc4473ffe22a68793b60992d8081a8.zip
tk-fd047f8e97cc4473ffe22a68793b60992d8081a8.tar.gz
tk-fd047f8e97cc4473ffe22a68793b60992d8081a8.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: 371181733dd5d3b15fc4e635e14bd0b307b9ad2a
Diffstat (limited to 'win/tkWinImage.c')
-rw-r--r--win/tkWinImage.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/win/tkWinImage.c b/win/tkWinImage.c
index bb20a88..dbbf3ba 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.6.2.1 2003/07/17 01:02:47 hobbs Exp $
+ * RCS: @(#) $Id: tkWinImage.c,v 1.6.2.2 2003/10/29 01:08:02 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;
@@ -456,19 +483,18 @@ XGetImageZPixmap(display, d, x, y, width, height, plane_mask, format)
/* Get the BITMAP info into the Image. */
if (GetDIBits(hdcMem, hbmp, 0, height, smallBitData, bmInfo,
- DIB_RGB_COLORS) == 0) {
+ DIB_RGB_COLORS) == 0) {
ckfree((char *) ret_image->data);
ckfree((char *) ret_image);
ckfree((char *) smallBitBase);
ret_image = NULL;
goto cleanup;
}
-
/* Copy the 24 Bit Pixmap to a 32-Bit one. */
for (h = 0; h < height; h++) {
bigBitData = ret_image->data + h * ret_image->bytes_per_line;
smallBitData = smallBitBase + h * byte_width;
-
+
for (w = 0; w < width; w++) {
*bigBitData++ = ((*smallBitData++));
*bigBitData++ = ((*smallBitData++));