diff options
author | das <das> | 2007-06-23 00:26:42 (GMT) |
---|---|---|
committer | das <das> | 2007-06-23 00:26:42 (GMT) |
commit | 38d17f35a89f5fafcba83303e7e244fe0f23967c (patch) | |
tree | a997e0607741d3d227de55048900359058c1fa3b /generic/tkImgPhoto.c | |
parent | ceaab853c21c70ff37a506c244e5f4210438f16a (diff) | |
download | tk-38d17f35a89f5fafcba83303e7e244fe0f23967c.zip tk-38d17f35a89f5fafcba83303e7e244fe0f23967c.tar.gz tk-38d17f35a89f5fafcba83303e7e244fe0f23967c.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/tkImgPhoto.c')
-rw-r--r-- | generic/tkImgPhoto.c | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c index 85d841b..3a2c3c3 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.36.2.17 2006/05/13 00:48:37 hobbs Exp $ + * RCS: @(#) $Id: tkImgPhoto.c,v 1.36.2.18 2007/06/23 00:26:42 das Exp $ */ #include "tkInt.h" @@ -2253,7 +2253,7 @@ ImgPhotoConfigureInstance(instancePtr) 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, @@ -2262,26 +2262,18 @@ ImgPhotoConfigureInstance(instancePtr) 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); } } @@ -4008,7 +4000,7 @@ DisposeInstance(clientData) 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); |