summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhobbs <hobbs>2006-03-02 20:45:19 (GMT)
committerhobbs <hobbs>2006-03-02 20:45:19 (GMT)
commitbf350cdb36feba9618507d0dc1578311fac837fb (patch)
treec814bab4e2d2c0fd2f7b528ebf641bf562230fd9
parentab38e376d5c828fb325ea1eb4dd28c5d24300952 (diff)
downloadtk-bf350cdb36feba9618507d0dc1578311fac837fb.zip
tk-bf350cdb36feba9618507d0dc1578311fac837fb.tar.gz
tk-bf350cdb36feba9618507d0dc1578311fac837fb.tar.bz2
* macosx/tkMacOSXDraw.c (TkPutImage): fix endian issue on OS X x86
displaying images. Bitmap images still have a black/white reversal issue, appears to be a general OS X issue (as seen in frogger demo).
-rw-r--r--ChangeLog7
-rw-r--r--macosx/tkMacOSXDraw.c52
2 files changed, 33 insertions, 26 deletions
diff --git a/ChangeLog b/ChangeLog
index 27faeb6..587b4f9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-03-02 Jeff Hobbs <jeffh@ActiveState.com>
+
+ * macosx/tkMacOSXDraw.c (TkPutImage): fix endian issue on OS X x86
+ displaying images. Bitmap images still have a black/white
+ reversal issue, appears to be a general OS X issue (as seen in
+ frogger demo).
+
2006-02-27 Donal K. Fellows <donal.k.fellows@manchester.ac.uk>
* generic/tkBitmap.c (Tk_GetBitmapFromData): Improve thread-safety.
diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c
index 77b71ab..7b5fdea 100644
--- a/macosx/tkMacOSXDraw.c
+++ b/macosx/tkMacOSXDraw.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXDraw.c,v 1.8 2005/12/08 07:50:13 das Exp $
+ * RCS: @(#) $Id: tkMacOSXDraw.c,v 1.9 2006/03/02 20:45:20 hobbs Exp $
*/
#include "tkInt.h"
@@ -381,18 +381,18 @@ XCopyPlane(
void
TkPutImage(
- unsigned long *colors, /* Unused on Macintosh. */
- int ncolors, /* Unused on Macintosh. */
- Display* display, /* Display. */
- Drawable d, /* Drawable to place image on. */
- GC gc, /* GC to use. */
- XImage* image, /* Image to place. */
- int src_x, /* Source X & Y. */
+ unsigned long *colors, /* Unused on Macintosh. */
+ int ncolors, /* Unused on Macintosh. */
+ Display* display, /* Display. */
+ Drawable d, /* Drawable to place image on. */
+ GC gc, /* GC to use. */
+ XImage* image, /* Image to place. */
+ int src_x, /* Source X & Y. */
int src_y,
- int dest_x, /* Destination X & Y. */
+ int dest_x, /* Destination X & Y. */
int dest_y,
- unsigned int width, /* Same width & height for both */
- unsigned int height) /* distination and source. */
+ unsigned int width, /* Same width & height for both */
+ unsigned int height) /* distination and source. */
{
CGrafPtr saveWorld;
GDHandle saveDevice;
@@ -422,9 +422,8 @@ TkPutImage(
GetPortBitMapForCopyBits(destPort),
&srcRect, &destRect, srcCopy, NULL);
} else if (image->depth == 1) {
-
- /*
- * This code assumes a pixel depth of 1
+ /*
+ * This code assumes a pixel depth of 1
*/
bitmap.bounds.top = bitmap.bounds.left = 0;
@@ -441,8 +440,8 @@ TkPutImage(
*newPtr = InvertByte((unsigned char) *oldPtr);
newPtr++, oldPtr++;
}
- *newPtr = 0;
- newPtr++;
+ *newPtr = 0;
+ newPtr++;
}
bitmap.baseAddr = newData;
bitmap.rowBytes = image->bytes_per_line + 1;
@@ -450,21 +449,18 @@ TkPutImage(
newData = (char *) ckalloc(image->height * image->bytes_per_line);
for (i = 0; i < image->height * image->bytes_per_line; i++) {
newData[i] = InvertByte((unsigned char) image->data[i]);
- }
+ }
bitmap.baseAddr = newData;
bitmap.rowBytes = image->bytes_per_line;
}
destBits = GetPortBitMapForCopyBits(destPort);
- CopyBits(&bitmap, destBits,
- &srcRect, &destRect, srcCopy, NULL);
-
+ CopyBits(&bitmap, destBits, &srcRect, &destRect, srcCopy, NULL);
} else {
- /*
- * Color image
+ /*
+ * Color image
*/
-
PixMap pixmap;
-
+
pixmap.bounds.left = 0;
pixmap.bounds.top = 0;
pixmap.bounds.right = (short) image->width;
@@ -478,16 +474,20 @@ TkPutImage(
pixmap.pixelSize = 32;
pixmap.cmpCount = 3;
pixmap.cmpSize = 8;
+#ifdef WORDS_BIGENDIAN
pixmap.pixelFormat = k32ARGBPixelFormat;
+#else
+ pixmap.pixelFormat = k32BGRAPixelFormat;
+#endif
pixmap.pmTable = NULL;
pixmap.pmExt = 0;
pixmap.baseAddr = image->data;
pixmap.rowBytes = image->bytes_per_line | 0x8000;
-
+
CopyBits((BitMap *) &pixmap, GetPortBitMapForCopyBits(destPort),
&srcRect, &destRect, srcCopy, NULL);
}
-
+
if (newData != NULL) {
ckfree(newData);
}