Browse Source

Review ExportImage() to use SaveFileData() #1779

Ray 4 years ago
parent
commit
4a099c3658
1 changed files with 7 additions and 1 deletions
  1. 7 1
      src/textures.c

+ 7 - 1
src/textures.c

@@ -416,7 +416,13 @@ bool ExportImage(Image image, const char *fileName)
     }
     }
 
 
 #if defined(SUPPORT_FILEFORMAT_PNG)
 #if defined(SUPPORT_FILEFORMAT_PNG)
-    if (IsFileExtension(fileName, ".png")) success = stbi_write_png(fileName, image.width, image.height, channels, imgData, image.width*channels);
+    if (IsFileExtension(fileName, ".png"))
+    {
+        int dataSize = 0;
+        unsigned char *fileData = stbi_write_png_to_mem((const unsigned char *)imgData, image.width*channels, image.width, image.height, channels, &dataSize);
+        success = SaveFileData(fileName, fileData, dataSize);
+        RL_FREE(fileData);
+    }
 #else
 #else
     if (false) {}
     if (false) {}
 #endif
 #endif