Merge pull request #8670 from Robyt3/Editor-Image-RGB-Cleanup

Remove unused code for saving embedded RGB map images
This commit is contained in:
Dennis Felsing 2024-07-31 21:47:58 +00:00 committed by GitHub
commit 0831aad325
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -111,27 +111,8 @@ bool CEditorMap::Save(const char *pFileName)
} }
else else
{ {
const size_t PixelSize = CImageInfo::PixelSize(CImageInfo::FORMAT_RGBA); dbg_assert(pImg->m_Format == CImageInfo::FORMAT_RGBA, "Embedded images must be in RGBA format");
const size_t DataSize = (size_t)Item.m_Width * Item.m_Height * PixelSize; Item.m_ImageData = Writer.AddData(pImg->DataSize(), pImg->m_pData);
if(pImg->m_Format == CImageInfo::FORMAT_RGB)
{
// Convert to RGBA
unsigned char *pDataRGBA = (unsigned char *)malloc(DataSize);
unsigned char *pDataRGB = (unsigned char *)pImg->m_pData;
for(int j = 0; j < Item.m_Width * Item.m_Height; j++)
{
pDataRGBA[j * PixelSize] = pDataRGB[j * 3];
pDataRGBA[j * PixelSize + 1] = pDataRGB[j * 3 + 1];
pDataRGBA[j * PixelSize + 2] = pDataRGB[j * 3 + 2];
pDataRGBA[j * PixelSize + 3] = 255;
}
Item.m_ImageData = Writer.AddData(DataSize, pDataRGBA);
free(pDataRGBA);
}
else
{
Item.m_ImageData = Writer.AddData(DataSize, pImg->m_pData);
}
} }
Writer.AddItem(MAPITEMTYPE_IMAGE, i, sizeof(Item), &Item); Writer.AddItem(MAPITEMTYPE_IMAGE, i, sizeof(Item), &Item);
} }