From 3ff9b0525422e718658637e27a1fb9d0954538fc Mon Sep 17 00:00:00 2001 From: Chlumsky Date: Tue, 27 Jul 2021 10:46:07 +0200 Subject: [PATCH] Fixed return value of saveImageText --- msdf-atlas-gen/image-save.hpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/msdf-atlas-gen/image-save.hpp b/msdf-atlas-gen/image-save.hpp index 81b3dc6..c5d0853 100644 --- a/msdf-atlas-gen/image-save.hpp +++ b/msdf-atlas-gen/image-save.hpp @@ -141,12 +141,12 @@ template bool saveImageText(const msdfgen::BitmapConstRef &bitmap, const char *filename, YDirection outputYDirection) { bool success = false; if (FILE *f = fopen(filename, "wb")) { + success = true; for (int y = 0; y < bitmap.height; ++y) { const byte *p = bitmap.pixels+N*bitmap.width*(outputYDirection == YDirection::TOP_DOWN ? bitmap.height-y-1 : y); - for (int x = 0; x < N*bitmap.width; ++x) { - fprintf(f, x ? " %02X" : "%02X", (unsigned) *p++); - } - fprintf(f, "\n"); + for (int x = 0; x < N*bitmap.width; ++x) + success &= fprintf(f, x ? " %02X" : "%02X", (unsigned) *p++) > 0; + success &= fprintf(f, "\n") > 0; } fclose(f); } @@ -157,12 +157,12 @@ template bool saveImageText(const msdfgen::BitmapConstRef &bitmap, const char *filename, YDirection outputYDirection) { bool success = false; if (FILE *f = fopen(filename, "wb")) { + success = true; for (int y = 0; y < bitmap.height; ++y) { const float *p = bitmap.pixels+N*bitmap.width*(outputYDirection == YDirection::TOP_DOWN ? bitmap.height-y-1 : y); - for (int x = 0; x < N*bitmap.width; ++x) { - fprintf(f, x ? " %g" : "%g", *p++); - } - fprintf(f, "\n"); + for (int x = 0; x < N*bitmap.width; ++x) + success &= fprintf(f, x ? " %g" : "%g", *p++) > 0; + success &= fprintf(f, "\n") > 0; } fclose(f); }