use first unused colour for the mask instead of hardcoded #ff00ff (patch 1746895)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47268 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-07-09 17:08:20 +00:00
parent a6ac8d7582
commit 1ffeecf7a9

View File

@@ -733,11 +733,6 @@ wxImage wxXPMDecoder::ReadData(const char* const* xpm_data)
if ( isNone ) if ( isNone )
{ {
img.SetMask(true);
img.SetMaskColour(255, 0, 255);
clr_data.R =
clr_data.B = 255;
clr_data.G = 0;
hasMask = true; hasMask = true;
maskKey = key; maskKey = key;
} }
@@ -745,22 +740,23 @@ wxImage wxXPMDecoder::ReadData(const char* const* xpm_data)
clr_tbl[key] = clr_data; clr_tbl[key] = clr_data;
} }
/* // deal with the mask: we must replace pseudo-colour "None" with the mask
* Modify colour entries with RGB = (255,0,255) to (255,0,254) if // colour (which can be any colour not otherwise used in the image)
* mask colour is present (so that existing pixels with (255,0,255)
* magenta colour are not incorrectly made transparent):
*/
if (hasMask) if (hasMask)
{ {
for (it = clr_tbl.begin(); it != clr_tbl.end(); ++it) unsigned char r, g, b;
if ( !img.FindFirstUnusedColour(&r, &g, &b) )
{ {
if (it->second.R == 255 && it->second.G == 0 && wxLogError(_("XPM: no colors left to use for mask!"));
it->second.B == 255 && return wxNullImage;
it->first != maskKey)
{
it->second.B = 254;
}
} }
clr_tbl[maskKey].R = r;
clr_tbl[maskKey].G = g;
clr_tbl[maskKey].B = b;
img.SetMask(true);
img.SetMaskColour(r, g, b);
} }
/* /*