From ff520c14d21106589fd048bb9214e2660a3fda84 Mon Sep 17 00:00:00 2001 From: Gaspar Capello Date: Fri, 4 Oct 2024 10:37:28 -0300 Subject: [PATCH] Fix transparency issue with new color criterias (fix #4686) Prior to this fix, the following particular conditions caused an incorrect conversion of an opaque color to a transparent color during RGBA->Indexed conversion: - RGBA image with black color (#000000 a=255) painted on the canvas - The black color is absent from the palette. - The mask color is present in the palette - Converts the sprite to indexed color mode using Sprite > Color Mode > More Options - Select Advanced Options, select a Color Best Fit Criteria other than Default (for example CIELAB) and press OK - The original black color becomes the mask color. --- src/doc/rgbmap_base.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rgbmap_base.cpp b/src/doc/rgbmap_base.cpp index 53d97256d..e0c28bd9e 100644 --- a/src/doc/rgbmap_base.cpp +++ b/src/doc/rgbmap_base.cpp @@ -120,7 +120,7 @@ int RgbMapBase::findBestfit(int r, int g, int b, int a, const double aDiff = double(a - rgba_geta(rgb)) / 128.0; double diff = xDiff * xDiff + yDiff * yDiff + zDiff * zDiff + aDiff * aDiff; - if (diff < lowest) { + if (diff < lowest && i != mask_index) { lowest = diff; bestfit = i; }