diff options
| author | Ray <[email protected]> | 2020-11-22 00:10:16 +0100 |
|---|---|---|
| committer | Ray <[email protected]> | 2020-11-22 00:10:16 +0100 |
| commit | bb9d734f69f70be641b7db9c8a573fb4fb5b8ee8 (patch) | |
| tree | 2af4f7faf367999c71c7e612a60537604a37c6fd /src/textures.c | |
| parent | 36dc302c25fc8143f2c8c45d6d101c7043e15872 (diff) | |
| download | raylib-bb9d734f69f70be641b7db9c8a573fb4fb5b8ee8.tar.gz raylib-bb9d734f69f70be641b7db9c8a573fb4fb5b8ee8.zip | |
Exposing some file access results to user layer #1420
Diffstat (limited to 'src/textures.c')
| -rw-r--r-- | src/textures.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/textures.c b/src/textures.c index cd468b2a..897905cf 100644 --- a/src/textures.c +++ b/src/textures.c @@ -395,7 +395,7 @@ void UnloadImage(Image image) // Export image data to file // NOTE: File format depends on fileName extension -void ExportImage(Image image, const char *fileName) +bool ExportImage(Image image, const char *fileName) { int success = 0; @@ -436,8 +436,7 @@ void ExportImage(Image image, const char *fileName) { // Export raw pixel data (without header) // NOTE: It's up to the user to track image parameters - SaveFileData(fileName, image.data, GetPixelDataSize(image.width, image.height, image.format)); - success = true; + success = SaveFileData(fileName, image.data, GetPixelDataSize(image.width, image.height, image.format)); } if (allocatedData) RL_FREE(imgData); @@ -445,11 +444,15 @@ void ExportImage(Image image, const char *fileName) if (success != 0) TRACELOG(LOG_INFO, "FILEIO: [%s] Image exported successfully", fileName); else TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to export image", fileName); + + return success; } // Export image as code file (.h) defining an array of bytes -void ExportImageAsCode(Image image, const char *fileName) +bool ExportImageAsCode(Image image, const char *fileName) { + bool success = false; + #ifndef TEXT_BYTES_PER_LINE #define TEXT_BYTES_PER_LINE 20 #endif @@ -488,9 +491,11 @@ void ExportImageAsCode(Image image, const char *fileName) bytesCount += sprintf(txtData + bytesCount, "0x%x };\n", ((unsigned char *)image.data)[dataSize - 1]); // NOTE: Text data length exported is determined by '\0' (NULL) character - SaveFileText(fileName, txtData); + success = SaveFileText(fileName, txtData); RL_FREE(txtData); + + return success; } //------------------------------------------------------------------------------------ @@ -4230,12 +4235,12 @@ static int SaveKTX(Image image, const char *fileName) } } - SaveFileData(fileName, fileData, dataSize); + int success = SaveFileData(fileName, fileData, dataSize); RL_FREE(fileData); // Free file data buffer // If all data has been written correctly to file, success = 1 - return true; + return success; } #endif |
