From fd1cc863b4663d8d577411cf11335ae440a5726b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Wed, 31 Jul 2024 22:11:15 +0200 Subject: [PATCH] Remove unused code for saving embedded RGB map images Only embedded images in RGBA format are loaded anymore, so the additional code for converting RGB to RGBA image data is not necessary. --- src/game/editor/mapitems/map_io.cpp | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/src/game/editor/mapitems/map_io.cpp b/src/game/editor/mapitems/map_io.cpp index 8d4e83c70..a3346b1a2 100644 --- a/src/game/editor/mapitems/map_io.cpp +++ b/src/game/editor/mapitems/map_io.cpp @@ -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); }