summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordas <das>2007-06-23 00:25:38 (GMT)
committerdas <das>2007-06-23 00:25:38 (GMT)
commit4e2bd974f22a0d3872a1939e38a365d9a62e14e3 (patch)
tree148eb739926f285c24f4ff371245704b03fb7eed /generic
parent9d7962e08c7e8fead868040687c9508363a26da4 (diff)
downloadtk-4e2bd974f22a0d3872a1939e38a365d9a62e14e3.zip
tk-4e2bd974f22a0d3872a1939e38a365d9a62e14e3.tar.gz
tk-4e2bd974f22a0d3872a1939e38a365d9a62e14e3.tar.bz2
* generic/tkImgPhoto.c (ImgPhotoConfigureInstance, DisposeInstance):
use XDestroyImage instead of XFree to destroy XImage; replace runtime endianness determination by compile-time check for WORDS_BIGENDIAN. * xlib/ximage.c (XCreateBitmapFromData): use XCreateImage and XDestroyImage instead of creating XImage structure manually.
Diffstat (limited to 'generic')
-rw-r--r--generic/tkImgPhoto.c31
1 files changed, 12 insertions, 19 deletions
diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c
index e9e5b0c..15662eb 100644
--- a/generic/tkImgPhoto.c
+++ b/generic/tkImgPhoto.c
@@ -17,7 +17,7 @@
* Department of Computer Science,
* Australian National University.
*
- * RCS: @(#) $Id: tkImgPhoto.c,v 1.69 2007/05/14 20:58:27 dgp Exp $
+ * RCS: @(#) $Id: tkImgPhoto.c,v 1.70 2007/06/23 00:25:38 das Exp $
*/
#include "tkInt.h"
@@ -2260,7 +2260,7 @@ ImgPhotoConfigureInstance(
if ((instancePtr->imagePtr == NULL)
|| (instancePtr->imagePtr->bits_per_pixel != bitsPerPixel)) {
if (instancePtr->imagePtr != NULL) {
- XFree((char *) instancePtr->imagePtr);
+ XDestroyImage(instancePtr->imagePtr);
}
imagePtr = XCreateImage(instancePtr->display,
instancePtr->visualInfo.visual, (unsigned) bitsPerPixel,
@@ -2269,25 +2269,18 @@ ImgPhotoConfigureInstance(
instancePtr->imagePtr = imagePtr;
/*
- * Determine the endianness of this machine. We create images
- * using the local host's endianness, rather than the endianness
- * of the server; otherwise we would have to byte-swap any 16 or
- * 32 bit values that we store in the image in those situations
- * where the server's endianness is different from ours.
- *
- * FIXME: use autoconf to figure this out.
+ * We create images using the local host's endianness, rather than
+ * the endianness of the server; otherwise we would have to
+ * byte-swap any 16 or 32 bit values that we store in the image
+ * if the server's endianness is different from ours.
*/
if (imagePtr != NULL) {
- union {
- int i;
- char c[sizeof(int)];
- } kludge;
-
- imagePtr->bitmap_unit = sizeof(pixel) * NBBY;
- kludge.i = 0;
- kludge.c[0] = 1;
- imagePtr->byte_order = (kludge.i == 1) ? LSBFirst : MSBFirst;
+#ifdef WORDS_BIGENDIAN
+ imagePtr->byte_order = MSBFirst;
+#else
+ imagePtr->byte_order = LSBFirst;
+#endif
_XInitImageFuncPtrs(imagePtr);
}
}
@@ -4006,7 +3999,7 @@ DisposeInstance(
Tk_FreeGC(instancePtr->display, instancePtr->gc);
}
if (instancePtr->imagePtr != NULL) {
- XFree((char *) instancePtr->imagePtr);
+ XDestroyImage(instancePtr->imagePtr);
}
if (instancePtr->error != NULL) {
ckfree((char *) instancePtr->error);