Changed: Use new methods in panoply_maker
This commit is contained in:
parent
6980bf3089
commit
bd7c17102a
1 changed files with 30 additions and 49 deletions
|
@ -669,41 +669,19 @@ static void BuildColoredVersionForOneBitmap(const CBuildInfo &bi, const std::str
|
||||||
// we can save it as RGB to optimize it
|
// we can save it as RGB to optimize it
|
||||||
if (bi.OptimizeTextures > 0 && depth == 32)
|
if (bi.OptimizeTextures > 0 && depth == 32)
|
||||||
{
|
{
|
||||||
uint32 size = srcBitmap.getPixels().size();
|
uint8 value = 0;
|
||||||
|
|
||||||
if (size > 0)
|
|
||||||
{
|
|
||||||
// get a pointer on original data
|
|
||||||
uint8 *data = srcBitmap.getPixels().getPtr();
|
|
||||||
|
|
||||||
// pointer on first alpha value
|
|
||||||
uint8 *tmp = data + 3;
|
|
||||||
uint8 *endData = data + size;
|
|
||||||
uint8 value = *tmp;
|
|
||||||
|
|
||||||
// check if all alphas have the same value
|
|
||||||
while(tmp < endData && *tmp == value) tmp += 4;
|
|
||||||
|
|
||||||
// texture can be converted if all alphas are 0 or 255
|
// texture can be converted if all alphas are 0 or 255
|
||||||
if (tmp >= endData && (value == 255 || value == 0))
|
if (srcBitmap.isAlphaUniform(&value) && (value == 255 || value == 0))
|
||||||
{
|
{
|
||||||
if (bi.OptimizeTextures > 1)
|
if (bi.OptimizeTextures > 1)
|
||||||
{
|
{
|
||||||
|
// make bitmap opaque
|
||||||
|
srcBitmap.makeOpaque();
|
||||||
|
|
||||||
// original depth is now 24 bits, since we discarded alpha channel
|
// original depth is now 24 bits, since we discarded alpha channel
|
||||||
depth = 24;
|
depth = 24;
|
||||||
|
|
||||||
// if texture is fully transparent, make it fully opaque
|
|
||||||
if (value == 0)
|
|
||||||
{
|
|
||||||
tmp = data + 3;
|
|
||||||
|
|
||||||
while(tmp < endData)
|
|
||||||
{
|
|
||||||
*tmp = 255;
|
|
||||||
tmp += 4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
NLMISC::COFile os;
|
NLMISC::COFile os;
|
||||||
|
|
||||||
if (os.open(fullInputBitmapPath))
|
if (os.open(fullInputBitmapPath))
|
||||||
|
@ -726,6 +704,10 @@ static void BuildColoredVersionForOneBitmap(const CBuildInfo &bi, const std::str
|
||||||
nlwarning("Don't support %s format for texture, unable to save it", ext.c_str());
|
nlwarning("Don't support %s format for texture, unable to save it", ext.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nlwarning("Unable to save texture %s", fullInputBitmapPath.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -733,7 +715,6 @@ static void BuildColoredVersionForOneBitmap(const CBuildInfo &bi, const std::str
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (srcBitmap.PixelFormat != NLMISC::CBitmap::RGBA)
|
if (srcBitmap.PixelFormat != NLMISC::CBitmap::RGBA)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue