mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-12-12 12:14:48 +00:00
Fixed: If mask is using colors, convert it to grayscale using Red value (compatible with previous algorithm)
This commit is contained in:
parent
3f2959f668
commit
6f69256c48
1 changed files with 36 additions and 33 deletions
|
@ -791,16 +791,15 @@ static void BuildColoredVersionForOneBitmap(const CBuildInfo &bi, const std::str
|
|||
throw NLMISC::Exception("Failed to load mask");
|
||||
}
|
||||
|
||||
// masks can be converted to grayscale files
|
||||
if (bi.OptimizeTextures > 0 && maskDepth > 8)
|
||||
// convert color mask to grayscale (red is the new gray value)
|
||||
if (li.Mask.getPixelFormat() == CBitmap::RGBA)
|
||||
{
|
||||
if (!li.Mask.isGrayscale())
|
||||
// display a warning if checks enabled
|
||||
if (bi.OptimizeTextures > 0 && !li.Mask.isGrayscale())
|
||||
{
|
||||
nlwarning("Mask %s is using colors, results may by incorrect! Use OptimizeTextures = 2 to fix it.", maskFileName.c_str());
|
||||
}
|
||||
|
||||
if (bi.OptimizeTextures > 1)
|
||||
{
|
||||
// get a pointer on original data
|
||||
uint32 size = li.Mask.getPixels().size();
|
||||
uint32 *data = (uint32*)li.Mask.getPixels().getPtr();
|
||||
|
@ -822,10 +821,19 @@ static void BuildColoredVersionForOneBitmap(const CBuildInfo &bi, const std::str
|
|||
|
||||
++data;
|
||||
}
|
||||
}
|
||||
|
||||
// convert image to real grayscale
|
||||
if (li.Mask.PixelFormat != NLMISC::CBitmap::Luminance)
|
||||
{
|
||||
li.Mask.convertToType(NLMISC::CBitmap::Luminance);
|
||||
}
|
||||
|
||||
// masks can be converted to grayscale files
|
||||
if (bi.OptimizeTextures > 0 && maskDepth > 8)
|
||||
{
|
||||
if (bi.OptimizeTextures > 1)
|
||||
{
|
||||
NLMISC::COFile os;
|
||||
|
||||
if (os.open(maskFileName))
|
||||
|
@ -855,11 +863,6 @@ static void BuildColoredVersionForOneBitmap(const CBuildInfo &bi, const std::str
|
|||
}
|
||||
}
|
||||
|
||||
if (li.Mask.PixelFormat != NLMISC::CBitmap::Luminance)
|
||||
{
|
||||
li.Mask.convertToType(NLMISC::CBitmap::Luminance);
|
||||
}
|
||||
|
||||
/// make sure the mask has the same size
|
||||
if (li.Mask.getWidth() != srcBitmap.getWidth()
|
||||
|| li.Mask.getHeight() != srcBitmap.getHeight())
|
||||
|
|
Loading…
Reference in a new issue