Skip to content

Commit

Permalink
Remove unused code for saving embedded RGB map images
Browse files Browse the repository at this point in the history
Only embedded images in RGBA format are loaded anymore, so the additional code for converting RGB to RGBA image data is not necessary.
  • Loading branch information
Robyt3 committed Jul 31, 2024
1 parent 3ff3802 commit fd1cc86
Showing 1 changed file with 2 additions and 21 deletions.
23 changes: 2 additions & 21 deletions src/game/editor/mapitems/map_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,27 +111,8 @@ bool CEditorMap::Save(const char *pFileName)
}
else
{
const size_t PixelSize = CImageInfo::PixelSize(CImageInfo::FORMAT_RGBA);
const size_t DataSize = (size_t)Item.m_Width * Item.m_Height * PixelSize;
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);
}
dbg_assert(pImg->m_Format == CImageInfo::FORMAT_RGBA, "Embedded images must be in RGBA format");
Item.m_ImageData = Writer.AddData(pImg->DataSize(), pImg->m_pData);
}
Writer.AddItem(MAPITEMTYPE_IMAGE, i, sizeof(Item), &Item);
}
Expand Down

0 comments on commit fd1cc86

Please sign in to comment.