506c618a765b5e0eb4088ac910e2927e7d7a9fde hiram Thu Jan 27 09:51:46 2011 -0800 using MEMGFX_BIGENDIAN for building on BIGENDIAN machines diff --git src/lib/memgfx.c src/lib/memgfx.c index 6680163..025fb79 100644 --- src/lib/memgfx.c +++ src/lib/memgfx.c @@ -123,65 +123,76 @@ void mgClearPixels(struct memGfx *mg) /* Set all pixels to background. */ { #ifdef COLOR32 memset((unsigned char *)mg->pixels, 0xff, mg->width*mg->height*sizeof(unsigned int)); #else zeroBytes(mg->pixels, mg->width*mg->height); #endif } void mgClearPixelsTrans(struct memGfx *mg) /* Set all pixels to transparent. */ { #ifdef COLOR32 -unsigned *ptr = mg->pixels; -unsigned *lastPtr = &mg->pixels[mg->width * mg->height]; +unsigned int *ptr = mg->pixels; +unsigned int *lastPtr = &mg->pixels[mg->width * mg->height]; for(; ptr < lastPtr; ptr++) - *ptr = 0xffffff; // transparent white +#ifdef MEMGFX_BIGENDIAN + *ptr = 0xffffff00; +#else + *ptr = 0x00ffffff; // transparent white +#endif + #else zeroBytes(mg->pixels, mg->width*mg->height); #endif } Color mgFindColor(struct memGfx *mg, unsigned char r, unsigned char g, unsigned char b) /* Returns closest color in color map to rgb values. If it doesn't * already exist in color map and there's room, it will create * exact color in map. */ { #ifdef COLOR32 return MAKECOLOR_32(r,g,b); #else struct colHashEl *che; if ((che = colHashLookup(mg->colorHash, r, g, b)) != NULL) return che->ix; if (mgColorsFree(mg)) return mgAddColor(mg, r, g, b); return mgClosestColor(mg, r, g, b); #endif } struct rgbColor mgColorIxToRgb(struct memGfx *mg, int colorIx) /* Return rgb value at color index. */ { #ifdef COLOR32 static struct rgbColor rgb; +#ifdef MEMGFX_BIGENDIAN +rgb.r = (colorIx >> 24) & 0xff; +rgb.g = (colorIx >> 16) & 0xff; +rgb.b = (colorIx >> 8) & 0xff; +#else rgb.r = (colorIx >> 0) & 0xff; rgb.g = (colorIx >> 8) & 0xff; rgb.b = (colorIx >> 16) & 0xff; +#endif return rgb; #else return mg->colorMap[colorIx]; #endif } Color mgClosestColor(struct memGfx *mg, unsigned char r, unsigned char g, unsigned char b) /* Returns closest color in color map to r,g,b */ { #ifdef COLOR32 return MAKECOLOR_32(r,g,b); #else struct rgbColor *c = mg->colorMap; int closestDist = 0x7fffffff;