From 1cad25e4b5d5c5e77194b481e80e802c9a60891b Mon Sep 17 00:00:00 2001 From: Yves Rizoud Date: Sun, 15 Aug 2010 18:34:25 +0000 Subject: [PATCH] Reverted r1477: 'Faster translucency effect when perfect matches are available'. When duplicates were available in the palette, it wasn't choosing always the same git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1575 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- src/windows.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/windows.c b/src/windows.c index 8f6f3b1d..50fe7f7d 100644 --- a/src/windows.c +++ b/src/windows.c @@ -2625,22 +2625,14 @@ byte Best_color(byte r,byte g,byte b) byte Best_color_nonexcluded(byte red,byte green,byte blue) { - // This "static" allows the loop to start on the last successful match. - // If the same color is requested again (and it happens often) and the match - // was perfect, it allows an early exit that avoids - // 255 computations of color distance. - // This system still works with no bad effects when the palette changes. - static byte col=0; - - byte end_color; + int col; int delta_r,delta_g,delta_b; int dist; int best_dist=0x7FFFFFFF; int rmean; byte best_color=0; - end_color=col; - do + for (col=0; col<256; col++) { delta_r=(int)Main_palette[col].R-red; delta_g=(int)Main_palette[col].G-green; @@ -2658,11 +2650,7 @@ byte Best_color_nonexcluded(byte red,byte green,byte blue) best_dist=dist; best_color=col; } - - // Loop - col++; - } while(col!=end_color); - + } return best_color; }