diff options
author | das <das> | 2007-07-09 08:30:31 (GMT) |
---|---|---|
committer | das <das> | 2007-07-09 08:30:31 (GMT) |
commit | dc26b700389d7dcdd93397c78a01d231c322af6e (patch) | |
tree | 682f41a04ecadd08d4ce1f26361bfc3587e34dce /macosx/tkMacOSXDraw.c | |
parent | 8c08129bc61f7b99269fd3b9a73a8cc4e14b40d5 (diff) | |
download | tk-dc26b700389d7dcdd93397c78a01d231c322af6e.zip tk-dc26b700389d7dcdd93397c78a01d231c322af6e.tar.gz tk-dc26b700389d7dcdd93397c78a01d231c322af6e.tar.bz2 |
* macosx/tkMacOSXDraw.c (TkPutImage): handle non-native XImage byte and
bit orders; reverse bits via xBitReverseTable instead of InvertByte().
Diffstat (limited to 'macosx/tkMacOSXDraw.c')
-rw-r--r-- | macosx/tkMacOSXDraw.c | 75 |
1 files changed, 26 insertions, 49 deletions
diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index d978ff5..8960567 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -12,11 +12,12 @@ * 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.28 2007/07/02 13:06:14 das Exp $ + * RCS: @(#) $Id: tkMacOSXDraw.c,v 1.2.2.29 2007/07/09 08:30:31 das Exp $ */ #include "tkMacOSXPrivate.h" #include "tkMacOSXDebug.h" +#include "xbytes.h" #include "tclInt.h" /* for Tcl_CreateNamespace() */ @@ -53,7 +54,7 @@ static int useThemedFrame = 0; /* * Prototypes for functions used only in this file. */ -static unsigned char InvertByte(unsigned char data); + static void ClipToGC(Drawable d, GC gc, CGrafPtr port, RgnHandle clipRgn); static void NoQDClip(CGrafPtr port); @@ -375,7 +376,7 @@ TkPutImage( } bitmap.bounds.top = bitmap.bounds.left = 0; bitmap.bounds.bottom = (short) image->height; - dataPtr = image->data; + dataPtr = image->data + image->xoffset; do { if (slices) { bitmap.bounds.right = bitmap.bounds.left + sliceWidth; @@ -389,15 +390,26 @@ TkPutImage( newData = ckalloc(image->height * (sliceRowBytes+odd)); } newPtr = newData; - for (i = 0; i < image->height; i++) { - for (j = 0; j < sliceRowBytes; j++) { - *newPtr = InvertByte((unsigned char) *oldPtr); - newPtr++; oldPtr++; + if (image->bitmap_bit_order != MSBFirst) { + for (i = 0; i < image->height; i++) { + for (j = 0; j < sliceRowBytes; j++) { + *newPtr = xBitReverseTable[(unsigned char)*oldPtr]; + newPtr++; oldPtr++; + } + if (odd) { + *newPtr++ = 0; + } + oldPtr += rowBytes - sliceRowBytes; } - if (odd) { - *newPtr++ = 0; + } else { + for (i = 0; i < image->height; i++) { + memcpy(newPtr, oldPtr, sliceRowBytes); + newPtr += sliceRowBytes; + if (odd) { + *newPtr++ = 0; + } + oldPtr += rowBytes; } - oldPtr += rowBytes - sliceRowBytes; } bitmap.baseAddr = newData; bitmap.rowBytes = sliceRowBytes + odd; @@ -428,11 +440,8 @@ TkPutImage( pixmap.pixelSize = 32; pixmap.cmpCount = 3; pixmap.cmpSize = 8; -#ifdef WORDS_BIGENDIAN - pixmap.pixelFormat = k32ARGBPixelFormat; -#else - pixmap.pixelFormat = k32BGRAPixelFormat; -#endif + pixmap.pixelFormat = image->byte_order == MSBFirst ? + k32ARGBPixelFormat : k32BGRAPixelFormat; pixmap.pmTable = NULL; pixmap.pmExt = 0; if (rowBytes > maxRowBytes) { @@ -445,7 +454,7 @@ TkPutImage( } sliceWidth = (long) image->width * maxRowBytes / rowBytes; lastSliceWidth = image->width - (sliceWidth * slices); - dataPtr = image->data; + dataPtr = image->data + image->xoffset; newData = (char *) ckalloc(image->height * sliceRowBytes); do { if (slices) { @@ -473,7 +482,7 @@ TkPutImage( ckfree(newData); } else { pixmap.bounds.right = (short) image->width; - pixmap.baseAddr = image->data; + pixmap.baseAddr = image->data + image->xoffset; pixmap.rowBytes = rowBytes | 0x8000; CopyBits((BitMap*) &pixmap, dstBit, srcPtr, dstPtr, srcCopy, NULL); } @@ -1883,38 +1892,6 @@ TkMacOSXMakeStippleMap( /* *---------------------------------------------------------------------- * - * InvertByte -- - * - * This function reverses the bits in the passed in Byte of data. - * - * Results: - * The incoming byte in reverse bit order. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static unsigned char -InvertByte( - unsigned char data) /* Byte of data. */ -{ - unsigned char i; - unsigned char mask = 1, result = 0; - - for (i = (1 << 7); i != 0; i /= 2) { - if (data & mask) { - result |= i; - } - mask = mask << 1; - } - return result; -} - -/* - *---------------------------------------------------------------------- - * * TkpDrawHighlightBorder -- * * This procedure draws a rectangular ring around the outside of |