Change PNG in function names to Png

- `LoadPNG` -> `LoadPng`
- `SavePNG` -> `SavePng`
- `LoadSkinPNG` -> `LoadSkinPng`
This commit is contained in:
Robert Müller 2024-04-12 17:22:52 +02:00
parent 06f330afb7
commit 8f7055f694
21 changed files with 46 additions and 46 deletions

View file

@ -500,7 +500,7 @@ IGraphics::CTextureHandle CGraphics_Threaded::LoadTexture(const char *pFilename,
dbg_assert(pFilename[0] != '\0', "Cannot load texture from file with empty filename"); // would cause Valgrind to crash otherwise dbg_assert(pFilename[0] != '\0', "Cannot load texture from file with empty filename"); // would cause Valgrind to crash otherwise
CImageInfo Img; CImageInfo Img;
if(LoadPNG(&Img, pFilename, StorageType)) if(LoadPng(&Img, pFilename, StorageType))
{ {
CTextureHandle Id = LoadTextureRawMove(Img, Flags, pFilename); CTextureHandle Id = LoadTextureRawMove(Img, Flags, pFilename);
if(Id.IsValid()) if(Id.IsValid())
@ -571,7 +571,7 @@ bool CGraphics_Threaded::UpdateTextTexture(CTextureHandle TextureId, int x, int
return true; return true;
} }
bool CGraphics_Threaded::LoadPNG(CImageInfo *pImg, const char *pFilename, int StorageType) bool CGraphics_Threaded::LoadPng(CImageInfo *pImg, const char *pFilename, int StorageType)
{ {
char aCompleteFilename[IO_MAX_PATH_LENGTH]; char aCompleteFilename[IO_MAX_PATH_LENGTH];
IOHANDLE File = m_pStorage->OpenFile(pFilename, IOFLAG_READ, StorageType, aCompleteFilename, sizeof(aCompleteFilename)); IOHANDLE File = m_pStorage->OpenFile(pFilename, IOFLAG_READ, StorageType, aCompleteFilename, sizeof(aCompleteFilename));
@ -598,7 +598,7 @@ bool CGraphics_Threaded::LoadPNG(CImageInfo *pImg, const char *pFilename, int St
uint8_t *pImgBuffer = NULL; uint8_t *pImgBuffer = NULL;
EImageFormat ImageFormat; EImageFormat ImageFormat;
int PngliteIncompatible; int PngliteIncompatible;
if(::LoadPNG(ImageByteBuffer, pFilename, PngliteIncompatible, pImg->m_Width, pImg->m_Height, pImgBuffer, ImageFormat)) if(::LoadPng(ImageByteBuffer, pFilename, PngliteIncompatible, pImg->m_Width, pImg->m_Height, pImgBuffer, ImageFormat))
{ {
if(ImageFormat == IMAGE_FORMAT_RGB) if(ImageFormat == IMAGE_FORMAT_RGB)
pImg->m_Format = CImageInfo::FORMAT_RGB; pImg->m_Format = CImageInfo::FORMAT_RGB;
@ -775,7 +775,7 @@ class CScreenshotSaveJob : public IJob
TImageByteBuffer ByteBuffer; TImageByteBuffer ByteBuffer;
SImageByteBuffer ImageByteBuffer(&ByteBuffer); SImageByteBuffer ImageByteBuffer(&ByteBuffer);
if(SavePNG(IMAGE_FORMAT_RGBA, m_pData, ImageByteBuffer, m_Width, m_Height)) if(SavePng(IMAGE_FORMAT_RGBA, m_pData, ImageByteBuffer, m_Width, m_Height))
io_write(File, &ByteBuffer.front(), ByteBuffer.size()); io_write(File, &ByteBuffer.front(), ByteBuffer.size());
io_close(File); io_close(File);

View file

@ -982,7 +982,7 @@ public:
// simple uncompressed RGBA loaders // simple uncompressed RGBA loaders
IGraphics::CTextureHandle LoadTexture(const char *pFilename, int StorageType, int Flags = 0) override; IGraphics::CTextureHandle LoadTexture(const char *pFilename, int StorageType, int Flags = 0) override;
bool LoadPNG(CImageInfo *pImg, const char *pFilename, int StorageType) override; bool LoadPng(CImageInfo *pImg, const char *pFilename, int StorageType) override;
bool CheckImageDivisibility(const char *pFileName, CImageInfo &Img, int DivX, int DivY, bool AllowResize) override; bool CheckImageDivisibility(const char *pFileName, CImageInfo &Img, int DivX, int DivY, bool AllowResize) override;
bool IsImageFormatRGBA(const char *pFileName, CImageInfo &Img) override; bool IsImageFormatRGBA(const char *pFileName, CImageInfo &Img) override;

View file

@ -124,7 +124,7 @@ static int PngliteIncompatibility(png_structp pPNGStruct, png_infop pPNGInfo)
return Result; return Result;
} }
bool LoadPNG(SImageByteBuffer &ByteLoader, const char *pFileName, int &PngliteIncompatible, int &Width, int &Height, uint8_t *&pImageBuff, EImageFormat &ImageFormat) bool LoadPng(SImageByteBuffer &ByteLoader, const char *pFileName, int &PngliteIncompatible, int &Width, int &Height, uint8_t *&pImageBuff, EImageFormat &ImageFormat)
{ {
SLibPNGWarningItem UserErrorStruct = {&ByteLoader, pFileName, {}}; SLibPNGWarningItem UserErrorStruct = {&ByteLoader, pFileName, {}};
@ -295,7 +295,7 @@ static int ImageLoaderHelperFormatToColorChannel(EImageFormat Format)
} }
} }
bool SavePNG(EImageFormat ImageFormat, const uint8_t *pRawBuffer, SImageByteBuffer &WrittenBytes, int Width, int Height) bool SavePng(EImageFormat ImageFormat, const uint8_t *pRawBuffer, SImageByteBuffer &WrittenBytes, int Width, int Height)
{ {
png_structp pPNGStruct = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr); png_structp pPNGStruct = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);

View file

@ -32,7 +32,7 @@ enum
PNGLITE_FILTER_TYPE = 1 << 4, PNGLITE_FILTER_TYPE = 1 << 4,
}; };
bool LoadPNG(SImageByteBuffer &ByteLoader, const char *pFileName, int &PngliteIncompatible, int &Width, int &Height, uint8_t *&pImageBuff, EImageFormat &ImageFormat); bool LoadPng(SImageByteBuffer &ByteLoader, const char *pFileName, int &PngliteIncompatible, int &Width, int &Height, uint8_t *&pImageBuff, EImageFormat &ImageFormat);
bool SavePNG(EImageFormat ImageFormat, const uint8_t *pRawBuffer, SImageByteBuffer &WrittenBytes, int Width, int Height); bool SavePng(EImageFormat ImageFormat, const uint8_t *pRawBuffer, SImageByteBuffer &WrittenBytes, int Width, int Height);
#endif // ENGINE_GFX_IMAGE_LOADER_H #endif // ENGINE_GFX_IMAGE_LOADER_H

View file

@ -335,7 +335,7 @@ public:
virtual const TTwGraphicsGpuList &GetGpus() const = 0; virtual const TTwGraphicsGpuList &GetGpus() const = 0;
virtual bool LoadPNG(CImageInfo *pImg, const char *pFilename, int StorageType) = 0; virtual bool LoadPng(CImageInfo *pImg, const char *pFilename, int StorageType) = 0;
virtual bool CheckImageDivisibility(const char *pFileName, CImageInfo &Img, int DivX, int DivY, bool AllowResize) = 0; virtual bool CheckImageDivisibility(const char *pFileName, CImageInfo &Img, int DivX, int DivY, bool AllowResize) = 0;
virtual bool IsImageFormatRGBA(const char *pFileName, CImageInfo &Img) = 0; virtual bool IsImageFormatRGBA(const char *pFileName, CImageInfo &Img) = 0;

View file

@ -63,7 +63,7 @@ void CCountryFlags::LoadCountryflagsIndexfile()
char aBuf[128]; char aBuf[128];
CImageInfo Info; CImageInfo Info;
str_format(aBuf, sizeof(aBuf), "countryflags/%s.png", aOrigin); str_format(aBuf, sizeof(aBuf), "countryflags/%s.png", aOrigin);
if(!Graphics()->LoadPNG(&Info, aBuf, IStorage::TYPE_ALL)) if(!Graphics()->LoadPng(&Info, aBuf, IStorage::TYPE_ALL))
{ {
char aMsg[128]; char aMsg[128];
str_format(aMsg, sizeof(aMsg), "failed to load '%s'", aBuf); str_format(aMsg, sizeof(aMsg), "failed to load '%s'", aBuf);

View file

@ -240,20 +240,20 @@ IGraphics::CTextureHandle CMapImages::GetEntities(EMapImageEntityLayerType Entit
CImageInfo ImgInfo; CImageInfo ImgInfo;
char aPath[IO_MAX_PATH_LENGTH]; char aPath[IO_MAX_PATH_LENGTH];
str_format(aPath, sizeof(aPath), "%s/%s.png", m_aEntitiesPath, gs_apModEntitiesNames[EntitiesModType]); str_format(aPath, sizeof(aPath), "%s/%s.png", m_aEntitiesPath, gs_apModEntitiesNames[EntitiesModType]);
Graphics()->LoadPNG(&ImgInfo, aPath, IStorage::TYPE_ALL); Graphics()->LoadPng(&ImgInfo, aPath, IStorage::TYPE_ALL);
// try as single ddnet replacement // try as single ddnet replacement
if(ImgInfo.m_pData == nullptr && EntitiesModType == MAP_IMAGE_MOD_TYPE_DDNET) if(ImgInfo.m_pData == nullptr && EntitiesModType == MAP_IMAGE_MOD_TYPE_DDNET)
{ {
str_format(aPath, sizeof(aPath), "%s.png", m_aEntitiesPath); str_format(aPath, sizeof(aPath), "%s.png", m_aEntitiesPath);
Graphics()->LoadPNG(&ImgInfo, aPath, IStorage::TYPE_ALL); Graphics()->LoadPng(&ImgInfo, aPath, IStorage::TYPE_ALL);
} }
// try default // try default
if(ImgInfo.m_pData == nullptr) if(ImgInfo.m_pData == nullptr)
{ {
str_format(aPath, sizeof(aPath), "editor/entities_clear/%s.png", gs_apModEntitiesNames[EntitiesModType]); str_format(aPath, sizeof(aPath), "editor/entities_clear/%s.png", gs_apModEntitiesNames[EntitiesModType]);
Graphics()->LoadPNG(&ImgInfo, aPath, IStorage::TYPE_ALL); Graphics()->LoadPng(&ImgInfo, aPath, IStorage::TYPE_ALL);
} }
if(ImgInfo.m_pData != nullptr) if(ImgInfo.m_pData != nullptr)

View file

@ -2314,7 +2314,7 @@ int CMenus::MenuImageScan(const char *pName, int IsDir, int DirType, void *pUser
str_format(aPath, sizeof(aPath), "menuimages/%s", pName); str_format(aPath, sizeof(aPath), "menuimages/%s", pName);
CImageInfo Info; CImageInfo Info;
if(!pSelf->Graphics()->LoadPNG(&Info, aPath, DirType)) if(!pSelf->Graphics()->LoadPng(&Info, aPath, DirType))
{ {
char aError[IO_MAX_PATH_LENGTH + 64]; char aError[IO_MAX_PATH_LENGTH + 64];
str_format(aError, sizeof(aError), "Failed to load menu image from '%s'", aPath); str_format(aError, sizeof(aError), "Failed to load menu image from '%s'", aPath);

View file

@ -1946,7 +1946,7 @@ const SCommunityIcon *CMenus::FindCommunityIcon(const char *pCommunityId)
bool CMenus::LoadCommunityIconFile(const char *pPath, int DirType, CImageInfo &Info, SHA256_DIGEST &Sha256) bool CMenus::LoadCommunityIconFile(const char *pPath, int DirType, CImageInfo &Info, SHA256_DIGEST &Sha256)
{ {
char aError[IO_MAX_PATH_LENGTH + 128]; char aError[IO_MAX_PATH_LENGTH + 128];
if(!Graphics()->LoadPNG(&Info, pPath, DirType)) if(!Graphics()->LoadPng(&Info, pPath, DirType))
{ {
str_format(aError, sizeof(aError), "Failed to load community icon from '%s'", pPath); str_format(aError, sizeof(aError), "Failed to load community icon from '%s'", pPath);
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "menus/browser", aError); Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "menus/browser", aError);

View file

@ -47,7 +47,7 @@ void CSkins::CGetPngFile::OnCompletion(EHttpState State)
// Maybe this should start another thread to load the png in instead of stalling the curl thread // Maybe this should start another thread to load the png in instead of stalling the curl thread
if(State == EHttpState::DONE) if(State == EHttpState::DONE)
{ {
m_pSkins->LoadSkinPNG(m_Info, Dest(), Dest(), IStorage::TYPE_SAVE); m_pSkins->LoadSkinPng(m_Info, Dest(), Dest(), IStorage::TYPE_SAVE);
} }
} }
@ -134,14 +134,14 @@ static void CheckMetrics(CSkin::SSkinMetricVariable &Metrics, const uint8_t *pIm
const CSkin *CSkins::LoadSkin(const char *pName, const char *pPath, int DirType) const CSkin *CSkins::LoadSkin(const char *pName, const char *pPath, int DirType)
{ {
CImageInfo Info; CImageInfo Info;
if(!LoadSkinPNG(Info, pName, pPath, DirType)) if(!LoadSkinPng(Info, pName, pPath, DirType))
return nullptr; return nullptr;
return LoadSkin(pName, Info); return LoadSkin(pName, Info);
} }
bool CSkins::LoadSkinPNG(CImageInfo &Info, const char *pName, const char *pPath, int DirType) bool CSkins::LoadSkinPng(CImageInfo &Info, const char *pName, const char *pPath, int DirType)
{ {
if(!Graphics()->LoadPNG(&Info, pPath, DirType)) if(!Graphics()->LoadPng(&Info, pPath, DirType))
{ {
log_error("skins", "Failed to load skin PNG: %s", pName); log_error("skins", "Failed to load skin PNG: %s", pName);
return false; return false;

View file

@ -83,7 +83,7 @@ private:
size_t m_DownloadingSkins = 0; size_t m_DownloadingSkins = 0;
char m_aEventSkinPrefix[24]; char m_aEventSkinPrefix[24];
bool LoadSkinPNG(CImageInfo &Info, const char *pName, const char *pPath, int DirType); bool LoadSkinPng(CImageInfo &Info, const char *pName, const char *pPath, int DirType);
const CSkin *LoadSkin(const char *pName, const char *pPath, int DirType); const CSkin *LoadSkin(const char *pName, const char *pPath, int DirType);
const CSkin *LoadSkin(const char *pName, CImageInfo &Info); const CSkin *LoadSkin(const char *pName, CImageInfo &Info);
const CSkin *FindImpl(const char *pName); const CSkin *FindImpl(const char *pName);

View file

@ -3030,7 +3030,7 @@ void CGameClient::LoadGameSkin(const char *pPath, bool AsDir)
} }
CImageInfo ImgInfo; CImageInfo ImgInfo;
bool PngLoaded = Graphics()->LoadPNG(&ImgInfo, aPath, IStorage::TYPE_ALL); bool PngLoaded = Graphics()->LoadPng(&ImgInfo, aPath, IStorage::TYPE_ALL);
if(!PngLoaded && !IsDefault) if(!PngLoaded && !IsDefault)
{ {
if(AsDir) if(AsDir)
@ -3191,7 +3191,7 @@ void CGameClient::LoadEmoticonsSkin(const char *pPath, bool AsDir)
} }
CImageInfo ImgInfo; CImageInfo ImgInfo;
bool PngLoaded = Graphics()->LoadPNG(&ImgInfo, aPath, IStorage::TYPE_ALL); bool PngLoaded = Graphics()->LoadPng(&ImgInfo, aPath, IStorage::TYPE_ALL);
if(!PngLoaded && !IsDefault) if(!PngLoaded && !IsDefault)
{ {
if(AsDir) if(AsDir)
@ -3245,7 +3245,7 @@ void CGameClient::LoadParticlesSkin(const char *pPath, bool AsDir)
} }
CImageInfo ImgInfo; CImageInfo ImgInfo;
bool PngLoaded = Graphics()->LoadPNG(&ImgInfo, aPath, IStorage::TYPE_ALL); bool PngLoaded = Graphics()->LoadPng(&ImgInfo, aPath, IStorage::TYPE_ALL);
if(!PngLoaded && !IsDefault) if(!PngLoaded && !IsDefault)
{ {
if(AsDir) if(AsDir)
@ -3333,7 +3333,7 @@ void CGameClient::LoadHudSkin(const char *pPath, bool AsDir)
} }
CImageInfo ImgInfo; CImageInfo ImgInfo;
bool PngLoaded = Graphics()->LoadPNG(&ImgInfo, aPath, IStorage::TYPE_ALL); bool PngLoaded = Graphics()->LoadPng(&ImgInfo, aPath, IStorage::TYPE_ALL);
if(!PngLoaded && !IsDefault) if(!PngLoaded && !IsDefault)
{ {
if(AsDir) if(AsDir)
@ -3407,7 +3407,7 @@ void CGameClient::LoadExtrasSkin(const char *pPath, bool AsDir)
} }
CImageInfo ImgInfo; CImageInfo ImgInfo;
bool PngLoaded = Graphics()->LoadPNG(&ImgInfo, aPath, IStorage::TYPE_ALL); bool PngLoaded = Graphics()->LoadPng(&ImgInfo, aPath, IStorage::TYPE_ALL);
if(!PngLoaded && !IsDefault) if(!PngLoaded && !IsDefault)
{ {
if(AsDir) if(AsDir)

View file

@ -866,7 +866,7 @@ bool CEditor::CallbackSaveImage(const char *pFileName, int StorageType, void *pU
TImageByteBuffer ByteBuffer; TImageByteBuffer ByteBuffer;
SImageByteBuffer ImageByteBuffer(&ByteBuffer); SImageByteBuffer ImageByteBuffer(&ByteBuffer);
if(SavePNG(OutputFormat, pImg->m_pData, ImageByteBuffer, pImg->m_Width, pImg->m_Height)) if(SavePng(OutputFormat, pImg->m_pData, ImageByteBuffer, pImg->m_Width, pImg->m_Height))
{ {
IOHANDLE File = pEditor->Storage()->OpenFile(pFileName, IOFLAG_WRITE, StorageType); IOHANDLE File = pEditor->Storage()->OpenFile(pFileName, IOFLAG_WRITE, StorageType);
if(File) if(File)
@ -4361,7 +4361,7 @@ bool CEditor::ReplaceImage(const char *pFileName, int StorageType, bool CheckDup
} }
CEditorImage ImgInfo(this); CEditorImage ImgInfo(this);
if(!Graphics()->LoadPNG(&ImgInfo, pFileName, StorageType)) if(!Graphics()->LoadPng(&ImgInfo, pFileName, StorageType))
{ {
ShowFileDialogError("Failed to load image from file '%s'.", pFileName); ShowFileDialogError("Failed to load image from file '%s'.", pFileName);
return false; return false;
@ -4424,7 +4424,7 @@ bool CEditor::AddImage(const char *pFileName, int StorageType, void *pUser)
} }
CEditorImage ImgInfo(pEditor); CEditorImage ImgInfo(pEditor);
if(!pEditor->Graphics()->LoadPNG(&ImgInfo, pFileName, StorageType)) if(!pEditor->Graphics()->LoadPng(&ImgInfo, pFileName, StorageType))
{ {
pEditor->ShowFileDialogError("Failed to load image from file '%s'.", pFileName); pEditor->ShowFileDialogError("Failed to load image from file '%s'.", pFileName);
return false; return false;
@ -5139,7 +5139,7 @@ void CEditor::RenderFileDialog()
{ {
char aBuffer[IO_MAX_PATH_LENGTH]; char aBuffer[IO_MAX_PATH_LENGTH];
str_format(aBuffer, sizeof(aBuffer), "%s/%s", m_pFileDialogPath, m_vpFilteredFileList[m_FilesSelectedIndex]->m_aFilename); str_format(aBuffer, sizeof(aBuffer), "%s/%s", m_pFileDialogPath, m_vpFilteredFileList[m_FilesSelectedIndex]->m_aFilename);
if(Graphics()->LoadPNG(&m_FilePreviewImageInfo, aBuffer, m_vpFilteredFileList[m_FilesSelectedIndex]->m_StorageType)) if(Graphics()->LoadPng(&m_FilePreviewImageInfo, aBuffer, m_vpFilteredFileList[m_FilesSelectedIndex]->m_StorageType))
{ {
Graphics()->UnloadTexture(&m_FilePreviewImage); Graphics()->UnloadTexture(&m_FilePreviewImage);
m_FilePreviewImage = Graphics()->LoadTextureRawMove(m_FilePreviewImageInfo, 0, aBuffer); m_FilePreviewImage = Graphics()->LoadTextureRawMove(m_FilePreviewImageInfo, 0, aBuffer);

View file

@ -1243,7 +1243,7 @@ void CEditorActionTileArt::Undo()
void CEditorActionTileArt::Redo() void CEditorActionTileArt::Redo()
{ {
if(!m_pEditor->Graphics()->LoadPNG(&m_pEditor->m_TileartImageInfo, m_aTileArtFile, IStorage::TYPE_ALL)) if(!m_pEditor->Graphics()->LoadPng(&m_pEditor->m_TileartImageInfo, m_aTileArtFile, IStorage::TYPE_ALL))
{ {
m_pEditor->ShowFileDialogError("Failed to load image from file '%s'.", m_aTileArtFile); m_pEditor->ShowFileDialogError("Failed to load image from file '%s'.", m_aTileArtFile);
return; return;

View file

@ -516,7 +516,7 @@ bool CEditorMap::Load(const char *pFileName, int StorageType, const std::functio
// load external // load external
CImageInfo ImgInfo; CImageInfo ImgInfo;
if(m_pEditor->Graphics()->LoadPNG(&ImgInfo, aBuf, IStorage::TYPE_ALL)) if(m_pEditor->Graphics()->LoadPng(&ImgInfo, aBuf, IStorage::TYPE_ALL))
{ {
pImg->m_Width = ImgInfo.m_Width; pImg->m_Width = ImgInfo.m_Width;
pImg->m_Height = ImgInfo.m_Height; pImg->m_Height = ImgInfo.m_Height;

View file

@ -238,7 +238,7 @@ bool CEditor::CallbackAddTileart(const char *pFilepath, int StorageType, void *p
{ {
CEditor *pEditor = (CEditor *)pUser; CEditor *pEditor = (CEditor *)pUser;
if(!pEditor->Graphics()->LoadPNG(&pEditor->m_TileartImageInfo, pFilepath, StorageType)) if(!pEditor->Graphics()->LoadPng(&pEditor->m_TileartImageInfo, pFilepath, StorageType))
{ {
pEditor->ShowFileDialogError("Failed to load image from file '%s'.", pFilepath); pEditor->ShowFileDialogError("Failed to load image from file '%s'.", pFilepath);
return false; return false;

View file

@ -31,7 +31,7 @@ int DilateFile(const char *pFilename)
CImageInfo Img; CImageInfo Img;
EImageFormat ImageFormat; EImageFormat ImageFormat;
int PngliteIncompatible; int PngliteIncompatible;
if(LoadPNG(ImageByteBuffer, pFilename, PngliteIncompatible, Img.m_Width, Img.m_Height, Img.m_pData, ImageFormat)) if(LoadPng(ImageByteBuffer, pFilename, PngliteIncompatible, Img.m_Width, Img.m_Height, Img.m_pData, ImageFormat))
{ {
if(ImageFormat != IMAGE_FORMAT_RGBA) if(ImageFormat != IMAGE_FORMAT_RGBA)
{ {
@ -49,7 +49,7 @@ int DilateFile(const char *pFilename)
TImageByteBuffer ByteBuffer2; TImageByteBuffer ByteBuffer2;
SImageByteBuffer ImageByteBuffer2(&ByteBuffer2); SImageByteBuffer ImageByteBuffer2(&ByteBuffer2);
if(SavePNG(IMAGE_FORMAT_RGBA, Img.m_pData, ImageByteBuffer2, Img.m_Width, Img.m_Height)) if(SavePng(IMAGE_FORMAT_RGBA, Img.m_pData, ImageByteBuffer2, Img.m_Width, Img.m_Height))
io_write(SaveFile, &ByteBuffer2.front(), ByteBuffer2.size()); io_write(SaveFile, &ByteBuffer2.front(), ByteBuffer2.size());
io_close(SaveFile); io_close(SaveFile);

View file

@ -25,7 +25,7 @@ int g_NextDataItemId = -1;
int g_aImageIds[MAX_MAPIMAGES]; int g_aImageIds[MAX_MAPIMAGES];
int LoadPNG(CImageInfo *pImg, const char *pFilename) int LoadPng(CImageInfo *pImg, const char *pFilename)
{ {
IOHANDLE File = io_open(pFilename, IOFLAG_READ); IOHANDLE File = io_open(pFilename, IOFLAG_READ);
if(File) if(File)
@ -50,7 +50,7 @@ int LoadPNG(CImageInfo *pImg, const char *pFilename)
uint8_t *pImgBuffer = NULL; uint8_t *pImgBuffer = NULL;
EImageFormat ImageFormat; EImageFormat ImageFormat;
int PngliteIncompatible; int PngliteIncompatible;
if(LoadPNG(ImageByteBuffer, pFilename, PngliteIncompatible, pImg->m_Width, pImg->m_Height, pImgBuffer, ImageFormat)) if(LoadPng(ImageByteBuffer, pFilename, PngliteIncompatible, pImg->m_Width, pImg->m_Height, pImgBuffer, ImageFormat))
{ {
pImg->m_pData = pImgBuffer; pImg->m_pData = pImgBuffer;
@ -120,7 +120,7 @@ void *ReplaceImageItem(int Index, CMapItemImage *pImgItem, CMapItemImage *pNewIm
CImageInfo ImgInfo; CImageInfo ImgInfo;
char aStr[IO_MAX_PATH_LENGTH]; char aStr[IO_MAX_PATH_LENGTH];
str_format(aStr, sizeof(aStr), "data/mapres/%s.png", pName); str_format(aStr, sizeof(aStr), "data/mapres/%s.png", pName);
if(!LoadPNG(&ImgInfo, aStr)) if(!LoadPng(&ImgInfo, aStr))
return pImgItem; // keep as external if we don't have a mapres to replace return pImgItem; // keep as external if we don't have a mapres to replace
if(ImgInfo.m_Format != CImageInfo::FORMAT_RGBA) if(ImgInfo.m_Format != CImageInfo::FORMAT_RGBA)

View file

@ -10,7 +10,7 @@ bool CreatePixelArt(const char[3][64], const int[2], const int[2], int[2], const
void InsertCurrentQuads(CDataFileReader &, CMapItemLayerQuads *, CQuad *); void InsertCurrentQuads(CDataFileReader &, CMapItemLayerQuads *, CQuad *);
int InsertPixelArtQuads(CQuad *, int &, const CImageInfo &, const int[2], const int[2], const bool[2]); int InsertPixelArtQuads(CQuad *, int &, const CImageInfo &, const int[2], const int[2], const bool[2]);
bool LoadPNG(CImageInfo *, const char *); bool LoadPng(CImageInfo *, const char *);
bool OpenMaps(const char[2][64], CDataFileReader &, CDataFileWriter &); bool OpenMaps(const char[2][64], CDataFileReader &, CDataFileWriter &);
void SaveOutputMap(CDataFileReader &, CDataFileWriter &, CMapItemLayerQuads *, int, CQuad *, int); void SaveOutputMap(CDataFileReader &, CDataFileWriter &, CMapItemLayerQuads *, int, CQuad *, int);
@ -67,7 +67,7 @@ int main(int argc, const char **argv)
bool CreatePixelArt(const char aFilenames[3][64], const int aLayerId[2], const int aStartingPos[2], int aPixelSizes[2], const bool aArtOptions[2]) bool CreatePixelArt(const char aFilenames[3][64], const int aLayerId[2], const int aStartingPos[2], int aPixelSizes[2], const bool aArtOptions[2])
{ {
CImageInfo Img; CImageInfo Img;
if(!LoadPNG(&Img, aFilenames[2])) if(!LoadPng(&Img, aFilenames[2]))
return false; return false;
aPixelSizes[0] = aPixelSizes[0] ? aPixelSizes[0] : GetImagePixelSize(Img); aPixelSizes[0] = aPixelSizes[0] ? aPixelSizes[0] : GetImagePixelSize(Img);
@ -309,7 +309,7 @@ CQuad CreateNewQuad(const float PosX, const float PosY, const int Width, const i
return Quad; return Quad;
} }
bool LoadPNG(CImageInfo *pImg, const char *pFilename) bool LoadPng(CImageInfo *pImg, const char *pFilename)
{ {
IOHANDLE File = io_open(pFilename, IOFLAG_READ); IOHANDLE File = io_open(pFilename, IOFLAG_READ);
if(!File) if(!File)
@ -338,7 +338,7 @@ bool LoadPNG(CImageInfo *pImg, const char *pFilename)
EImageFormat ImageFormat; EImageFormat ImageFormat;
int PngliteIncompatible; int PngliteIncompatible;
if(!LoadPNG(ImageByteBuffer, pFilename, PngliteIncompatible, pImg->m_Width, pImg->m_Height, pImgBuffer, ImageFormat)) if(!LoadPng(ImageByteBuffer, pFilename, PngliteIncompatible, pImg->m_Width, pImg->m_Height, pImgBuffer, ImageFormat))
{ {
dbg_msg("map_create_pixelart", "ERROR: Unable to load a valid PNG from file %s", pFilename); dbg_msg("map_create_pixelart", "ERROR: Unable to load a valid PNG from file %s", pFilename);
return false; return false;

View file

@ -80,7 +80,7 @@ bool Process(IStorage *pStorage, const char *pMapName, const char *pPathSave)
TImageByteBuffer ByteBuffer; TImageByteBuffer ByteBuffer;
SImageByteBuffer ImageByteBuffer(&ByteBuffer); SImageByteBuffer ImageByteBuffer(&ByteBuffer);
if(SavePNG(OutputFormat, (const uint8_t *)Reader.GetData(pItem->m_ImageData), ImageByteBuffer, pItem->m_Width, pItem->m_Height)) if(SavePng(OutputFormat, (const uint8_t *)Reader.GetData(pItem->m_ImageData), ImageByteBuffer, pItem->m_Width, pItem->m_Height))
io_write(File, &ByteBuffer.front(), ByteBuffer.size()); io_write(File, &ByteBuffer.front(), ByteBuffer.size());
io_close(File); io_close(File);
} }

View file

@ -23,7 +23,7 @@ int g_NewDataId = -1;
int g_NewDataSize = 0; int g_NewDataSize = 0;
void *g_pNewData = nullptr; void *g_pNewData = nullptr;
bool LoadPNG(CImageInfo *pImg, const char *pFilename) bool LoadPng(CImageInfo *pImg, const char *pFilename)
{ {
IOHANDLE File = io_open(pFilename, IOFLAG_READ); IOHANDLE File = io_open(pFilename, IOFLAG_READ);
if(File) if(File)
@ -47,7 +47,7 @@ bool LoadPNG(CImageInfo *pImg, const char *pFilename)
uint8_t *pImgBuffer = NULL; uint8_t *pImgBuffer = NULL;
EImageFormat ImageFormat; EImageFormat ImageFormat;
int PngliteIncompatible; int PngliteIncompatible;
if(LoadPNG(ImageByteBuffer, pFilename, PngliteIncompatible, pImg->m_Width, pImg->m_Height, pImgBuffer, ImageFormat)) if(LoadPng(ImageByteBuffer, pFilename, PngliteIncompatible, pImg->m_Width, pImg->m_Height, pImgBuffer, ImageFormat))
{ {
if((ImageFormat == IMAGE_FORMAT_RGBA || ImageFormat == IMAGE_FORMAT_RGB) && pImg->m_Width <= (2 << 13) && pImg->m_Height <= (2 << 13)) if((ImageFormat == IMAGE_FORMAT_RGBA || ImageFormat == IMAGE_FORMAT_RGB) && pImg->m_Width <= (2 << 13) && pImg->m_Height <= (2 << 13))
{ {
@ -87,7 +87,7 @@ void *ReplaceImageItem(int Index, CMapItemImage *pImgItem, const char *pImgName,
dbg_msg("map_replace_image", "found image '%s'", pImgName); dbg_msg("map_replace_image", "found image '%s'", pImgName);
CImageInfo ImgInfo; CImageInfo ImgInfo;
if(!LoadPNG(&ImgInfo, pImgFile)) if(!LoadPng(&ImgInfo, pImgFile))
return 0; return 0;
if(ImgInfo.m_Format != CImageInfo::FORMAT_RGBA) if(ImgInfo.m_Format != CImageInfo::FORMAT_RGBA)