summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--unix/tkUnixWm.c41
2 files changed, 24 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index f25103b..4ea12cb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-08-01 Donal K. Fellows <dkf@users.sf.net>
+
+ * unix/tkUnixWm.c (WmIconphotoCmd): [Bug 2830420]: Assemble the image
+ for the window manager in a way that doesn't assume we're on a little-
+ endian system.
+
2009-07-22 Donal K. Fellows <dkf@users.sf.net>
* generic/tkFocus.c (TkFocusDeadWindow): [Bug 2496114]: Ensure that
diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c
index d55c4ff..193c049 100644
--- a/unix/tkUnixWm.c
+++ b/unix/tkUnixWm.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkUnixWm.c,v 1.58.2.2 2009/04/04 03:11:50 jenglish Exp $
+ * RCS: @(#) $Id: tkUnixWm.c,v 1.58.2.3 2009/08/01 08:08:18 dkf Exp $
*/
#include "tkUnixInt.h"
@@ -2335,9 +2335,7 @@ WmIconphotoCmd(
Tk_PhotoHandle photo;
Tk_PhotoImageBlock block;
int i, size = 0, width, height, index = 0, x, y, isDefault = 0;
- long R, G, B, A;
- long *iconPropertyData;
- unsigned char *pixelByte;
+ unsigned int *iconPropertyData;
if (objc < 4) {
Tcl_WrongNumArgs(interp, 2, objv,
@@ -2380,11 +2378,12 @@ WmIconphotoCmd(
* memory space.
*/
- iconPropertyData = (long *) Tcl_AttemptAlloc(sizeof(long)*size);
+ iconPropertyData = (unsigned int *)
+ Tcl_AttemptAlloc(sizeof(unsigned int) * size);
if (iconPropertyData == NULL) {
return TCL_ERROR;
}
- memset(iconPropertyData, 0, sizeof(long)*size);
+ memset(iconPropertyData, 0, sizeof(unsigned int) * size);
for (i = 3 + isDefault; i < objc; i++) {
photo = Tk_FindPhoto(interp, Tcl_GetString(objv[i]));
@@ -2408,31 +2407,27 @@ WmIconphotoCmd(
*
* This is an array of 32bit packed CARDINAL ARGB with high byte being
* A, low byte being B. The first two cardinals are width, height.
- * Data is in rows, left to right and top to bottom.
+ * Data is in rows, left to right and top to bottom. The data will be
+ * endian-swapped going to the server if necessary. [Bug 2830420]
*/
/*
* Encode the image data in the iconPropertyData array.
*/
- iconPropertyData[index++] = width;
- iconPropertyData[index++] = height;
+ iconPropertyData[index++] = (unsigned) width;
+ iconPropertyData[index++] = (unsigned) height;
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
- R = *(block.pixelPtr + x*block.pixelSize +
- y*block.pitch + block.offset[0]);
- G = *(block.pixelPtr + x*block.pixelSize +
- y*block.pitch + block.offset[1]);
- B = *(block.pixelPtr + x*block.pixelSize +
- y*block.pitch + block.offset[2]);
- A = *(block.pixelPtr + x*block.pixelSize +
- y*block.pitch + block.offset[3]);
- pixelByte = (unsigned char *) &iconPropertyData[index];
- pixelByte[3] = A;
- pixelByte[2] = R;
- pixelByte[1] = G;
- pixelByte[0] = B;
- index++;
+ register unsigned char *pixelPtr =
+ block.pixelPtr + x*block.pixelSize + y*block.pitch;
+ register unsigned int R, G, B, A;
+
+ R = pixelPtr[block.offset[0]];
+ G = pixelPtr[block.offset[1]];
+ B = pixelPtr[block.offset[2]];
+ A = pixelPtr[block.offset[3]];
+ iconPropertyData[index++] = A<<24 | R<<16 | G<<8 | B<<0;
}
}
}