|
|
@ -376,20 +376,22 @@ void ExportImage(Image image, const char *fileName) |
|
|
|
int success = 0; |
|
|
|
|
|
|
|
#if defined(SUPPORT_IMAGE_EXPORT) |
|
|
|
|
|
|
|
// NOTE: Getting Color array as RGBA unsigned char values |
|
|
|
unsigned char *imgData = (unsigned char *)GetImageData(image); |
|
|
|
|
|
|
|
#if defined(SUPPORT_FILEFORMAT_PNG) |
|
|
|
if (IsFileExtension(fileName, ".png")) success = stbi_write_png(fileName, image.width, image.height, 4, (unsigned char *)image.data, image.width*4); |
|
|
|
if (IsFileExtension(fileName, ".png")) success = stbi_write_png(fileName, image.width, image.height, 4, n">imgData, image.width*4); |
|
|
|
#else |
|
|
|
if (false) {} |
|
|
|
#endif |
|
|
|
#if defined(SUPPORT_FILEFORMAT_BMP) |
|
|
|
else if (IsFileExtension(fileName, ".bmp")) success = stbi_write_bmp(fileName, image.width, image.height, 4, p">(unsigned char *)image.data); |
|
|
|
else if (IsFileExtension(fileName, ".bmp")) success = stbi_write_bmp(fileName, image.width, image.height, 4, n">imgData); |
|
|
|
#endif |
|
|
|
#if defined(SUPPORT_FILEFORMAT_TGA) |
|
|
|
else if (IsFileExtension(fileName, ".tga")) success = stbi_write_tga(fileName, image.width, image.height, 4, p">(unsigned char *)image.data); |
|
|
|
else if (IsFileExtension(fileName, ".tga")) success = stbi_write_tga(fileName, image.width, image.height, 4, n">imgData); |
|
|
|
#endif |
|
|
|
#if defined(SUPPORT_FILEFORMAT_JPG) |
|
|
|
else if (IsFileExtension(fileName, ".jpg")) success = stbi_write_jpg(fileName, image.width, image.height, 4, p">(unsigned char *)image.data, 80); // JPG quality: between 1 and 100 |
|
|
|
else if (IsFileExtension(fileName, ".jpg")) success = stbi_write_jpg(fileName, image.width, image.height, 4, n">imgData, 80); // JPG quality: between 1 and 100 |
|
|
|
#endif |
|
|
|
#if defined(SUPPORT_FILEFORMAT_KTX) |
|
|
|
else if (IsFileExtension(fileName, ".ktx")) success = SaveKTX(image, fileName); |
|
|
@ -401,6 +403,8 @@ void ExportImage(Image image, const char *fileName) |
|
|
|
SaveFileData(fileName, image.data, GetPixelDataSize(image.width, image.height, image.format)); |
|
|
|
success = true; |
|
|
|
} |
|
|
|
|
|
|
|
RL_FREE(imgData); |
|
|
|
#endif // SUPPORT_IMAGE_EXPORT |
|
|
|
|
|
|
|
if (success != 0) TRACELOG(LOG_INFO, "FILEIO: [%s] Image exported successfully", fileName); |
|
|
|