mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-06 14:23:12 +00:00
REVIEWED: ExportImage()
This commit is contained in:
parent
998a18b641
commit
12ce72c32d
@ -422,7 +422,7 @@ Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, i
|
|||||||
{
|
{
|
||||||
Image image = { 0 };
|
Image image = { 0 };
|
||||||
|
|
||||||
// Security check for input data
|
// Security checks for input data
|
||||||
if ((fileData == NULL) || (dataSize == 0))
|
if ((fileData == NULL) || (dataSize == 0))
|
||||||
{
|
{
|
||||||
TRACELOG(LOG_WARNING, "IMAGE: Invalid file data");
|
TRACELOG(LOG_WARNING, "IMAGE: Invalid file data");
|
||||||
@ -650,8 +650,9 @@ bool ExportImage(Image image, const char *fileName)
|
|||||||
allocatedData = true;
|
allocatedData = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (false) { 0 } // Required to attach following 'else' cases
|
||||||
#if defined(SUPPORT_FILEFORMAT_PNG)
|
#if defined(SUPPORT_FILEFORMAT_PNG)
|
||||||
if (IsFileExtension(fileName, ".png"))
|
else if (IsFileExtension(fileName, ".png"))
|
||||||
{
|
{
|
||||||
int dataSize = 0;
|
int dataSize = 0;
|
||||||
unsigned char *fileData = stbi_write_png_to_mem((const unsigned char *)imgData, image.width*channels, image.width, image.height, channels, &dataSize);
|
unsigned char *fileData = stbi_write_png_to_mem((const unsigned char *)imgData, image.width*channels, image.width, image.height, channels, &dataSize);
|
||||||
@ -701,7 +702,8 @@ bool ExportImage(Image image, const char *fileName)
|
|||||||
// NOTE: It's up to the user to track image parameters
|
// NOTE: It's up to the user to track image parameters
|
||||||
result = SaveFileData(fileName, image.data, GetPixelDataSize(image.width, image.height, image.format));
|
result = SaveFileData(fileName, image.data, GetPixelDataSize(image.width, image.height, image.format));
|
||||||
}
|
}
|
||||||
|
else TRACELOG(LOG_WARNING, "IMAGE: Export image format requested not supported");
|
||||||
|
|
||||||
if (allocatedData) RL_FREE(imgData);
|
if (allocatedData) RL_FREE(imgData);
|
||||||
#endif // SUPPORT_IMAGE_EXPORT
|
#endif // SUPPORT_IMAGE_EXPORT
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user