From f9e049ac8b11d86f3f13b5db332dbd0f6b52a2b4 Mon Sep 17 00:00:00 2001 From: hobbs Date: Thu, 2 Mar 2006 20:44:20 +0000 Subject: * 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). --- ChangeLog | 53 +++++++++++++++++++++++++-------------------- macosx/tkMacOSXDraw.c | 59 ++++++++++++++++++++++++++------------------------- 2 files changed, 60 insertions(+), 52 deletions(-) diff --git a/ChangeLog b/ChangeLog index 03abca9..f51a230 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-03-02 Jeff Hobbs + + * 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-03-02 Pat Thoyts * unix/tcl.m4: Fix for tk bug #1334613 to sort out shared library @@ -25,29 +32,29 @@ 2006-01-25 Don Porter - * library/bgerror.tcl: Updates to use Tcl 8.4 features. [Patch 1237759] - * library/button.tcl: - * library/choosedir.tcl: - * library/clrpick.tcl: - * library/comdlg.tcl: - * library/console.tcl: - * library/dialog.tcl: - * library/entry.tcl: - * library/focus.tcl: - * library/listbox.tcl: - * library/menu.tcl: - * library/msgbox.tcl: - * library/palette.tcl: - * library/panedwindow.tcl: - * library/safetk.tcl: - * library/scale.tcl: - * library/scrlbar.tcl: - * library/spinbox.tcl: - * library/tearoff.tcl: - * library/text.tcl: - * library/tk.tcl: - * library/tkfbox.tcl: - * library/xmfbox.tcl: + * library/bgerror.tcl: Updates to use Tcl 8.4 features. [Patch 1237759] + * library/button.tcl: + * library/choosedir.tcl: + * library/clrpick.tcl: + * library/comdlg.tcl: + * library/console.tcl: + * library/dialog.tcl: + * library/entry.tcl: + * library/focus.tcl: + * library/listbox.tcl: + * library/menu.tcl: + * library/msgbox.tcl: + * library/palette.tcl: + * library/panedwindow.tcl: + * library/safetk.tcl: + * library/scale.tcl: + * library/scrlbar.tcl: + * library/spinbox.tcl: + * library/tearoff.tcl: + * library/text.tcl: + * library/tk.tcl: + * library/tkfbox.tcl: + * library/xmfbox.tcl: 2006-01-23 Daniel Steffen diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index cfdfc22..e382a48 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.2.2.10 2006/01/10 05:38:20 das Exp $ + * RCS: @(#) $Id: tkMacOSXDraw.c,v 1.2.2.11 2006/03/02 20:44:25 hobbs Exp $ */ #include "tkInt.h" @@ -382,18 +382,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; @@ -423,9 +423,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; @@ -434,7 +433,7 @@ TkPutImage( if ((image->bytes_per_line % 2) == 1) { char *newPtr, *oldPtr; newData = (char *) ckalloc(image->height * - (image->bytes_per_line + 1)); + (image->bytes_per_line + 1)); newPtr = newData; oldPtr = image->data; for (i = 0; i < image->height; i++) { @@ -442,30 +441,28 @@ TkPutImage( *newPtr = InvertByte((unsigned char) *oldPtr); newPtr++, oldPtr++; } - *newPtr = 0; - newPtr++; + *newPtr = 0; + newPtr++; } bitmap.baseAddr = newData; bitmap.rowBytes = image->bytes_per_line + 1; } else { - newData = (char *) ckalloc(image->height * image->bytes_per_line); - for (i = 0; i < image->height * image->bytes_per_line; i++) { + size_t size = image->height * image->bytes_per_line; + newData = (char *) ckalloc((int) size); + for (i = 0; i < size; 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; @@ -479,16 +476,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); } -- cgit v0.12