From c061b76b935e9ee6b816690db9b94cb9dd4eaaf0 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Tue, 2 Jan 2001 23:09:02 +0000 Subject: [PATCH] errr - clean clean.. fix color pixle caclfor 8bpp and 8bpp non dithered had a.. er... bug :) SVN revision: 4073 --- src/image.c | 2 ++ src/rend.c | 5 +++++ src/rgba.c | 9 +++++---- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/image.c b/src/image.c index 28ae70d..941616d 100644 --- a/src/image.c +++ b/src/image.c @@ -1013,6 +1013,8 @@ __imlib_LoadImage(const char *file, ImlibProgressFunction progress, ImlibLoader *best_loader; char loader_ret = 0; + if (!file) return NULL; + if (file[0] == 0) return NULL; /* see if we alreayd have the image cached */ im = __imlib_FindCachedImage(file); /* if we found a cached image and we shoudl always check that it is */ diff --git a/src/rend.c b/src/rend.c index e31e092..641964c 100644 --- a/src/rend.c +++ b/src/rend.c @@ -66,6 +66,11 @@ __imlib_RenderGetPixel(Display *d, Drawable w, Visual *v, Colormap cm, int depth ((g >> 3) & 0x1b) | ((b >> 6) & 0x02)]; break; + case 7: /* 666 */ + return ct->palette[((int)(((double)r / 255) * 5.0) * 36) + + ((int)(((double)g / 255) * 5.0) * 6 ) + + ((int)(((double)b / 255) * 5.0) )]; + break; default: return 0; } diff --git a/src/rgba.c b/src/rgba.c index ce827e2..912244c 100644 --- a/src/rgba.c +++ b/src/rgba.c @@ -1,3 +1,4 @@ + #include "common.h" #ifndef X_DISPLAY_MISSING #include @@ -467,7 +468,7 @@ static DATA8 _dither_a1[8 * 8 * 256]; #ifdef WORDS_BIGENDIAN #define WRITE2_RGBA_RGB666(src, dest) \ { \ - *((DATA16 *)dest) = (_dither_color_lut[(_dither_666r[(src[1] >> 16) & 0xff] ) + \ + *((DATA32 *)dest) = (_dither_color_lut[(_dither_666r[(src[1] >> 16) & 0xff] ) + \ (_dither_666g[(src[1] >> 8 ) & 0xff] ) + \ (_dither_666b[(src[1] ) & 0xff] )]) | \ (_dither_color_lut[(_dither_666r[(src[0] >> 16) & 0xff] ) + \ @@ -477,7 +478,7 @@ static DATA8 _dither_a1[8 * 8 * 256]; } #define WRITE4_RGBA_RGB666(src, dest) \ { \ - *((DATA16 *)dest) = (_dither_color_lut[(_dither_666r[(src[3] >> 16) & 0xff] ) + \ + *((DATA32 *)dest) = (_dither_color_lut[(_dither_666r[(src[3] >> 16) & 0xff] ) + \ (_dither_666g[(src[3] >> 8 ) & 0xff] ) + \ (_dither_666b[(src[3] ) & 0xff] )]) | \ (_dither_color_lut[(_dither_666r[(src[2] >> 16) & 0xff] ) + \ @@ -494,7 +495,7 @@ static DATA8 _dither_a1[8 * 8 * 256]; #else #define WRITE2_RGBA_RGB666(src, dest) \ { \ - *((DATA16 *)dest) = (_dither_color_lut[(_dither_666r[(src[0] >> 16) & 0xff] ) + \ + *((DATA32 *)dest) = (_dither_color_lut[(_dither_666r[(src[0] >> 16) & 0xff] ) + \ (_dither_666g[(src[0] >> 8 ) & 0xff] ) + \ (_dither_666b[(src[0] ) & 0xff] )]) | \ (_dither_color_lut[(_dither_666r[(src[1] >> 16) & 0xff] ) + \ @@ -504,7 +505,7 @@ static DATA8 _dither_a1[8 * 8 * 256]; } #define WRITE4_RGBA_RGB666(src, dest) \ { \ - *((DATA16 *)dest) = (_dither_color_lut[(_dither_666r[(src[0] >> 16) & 0xff] ) + \ + *((DATA32 *)dest) = (_dither_color_lut[(_dither_666r[(src[0] >> 16) & 0xff] ) + \ (_dither_666g[(src[0] >> 8 ) & 0xff] ) + \ (_dither_666b[(src[0] ) & 0xff] )]) | \ (_dither_color_lut[(_dither_666r[(src[1] >> 16) & 0xff] ) + \