Skip to content

Commit

Permalink
Do not crash on broken images. Related: EasyRPG#858,EasyRPG#432
Browse files Browse the repository at this point in the history
This makes it also possible to degrades most image reader errors
to warnings, because Player can go on if one image is not useable.
  • Loading branch information
carstene1ns committed May 30, 2016
1 parent 0dde075 commit 329da6d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/bitmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,12 +552,13 @@ Bitmap::Bitmap(const std::string& filename, bool transparent, uint32_t flags) {
ImagePNG::ReadPNG(stream, (void*)NULL, transparent, w, h, pixels);
else
#endif
Output::Error("Unsupported image file %s", filename.c_str());
Output::Warning("Unsupported image file %s", filename.c_str());

fclose(stream);

Init(w, h, (void *) NULL);
ConvertImage(w, h, pixels, transparent);
if (pixels)
ConvertImage(w, h, pixels, transparent);

CheckPixels(flags);
}
Expand Down Expand Up @@ -586,10 +587,11 @@ Bitmap::Bitmap(const uint8_t* data, unsigned bytes, bool transparent, uint32_t f
ImagePNG::ReadPNG((FILE*) NULL, (const void*) data, transparent, w, h, pixels);
else
#endif
Output::Error("Unsupported image");
Output::Warning("Unsupported image");

Init(w, h, (void *) NULL);
ConvertImage(w, h, pixels, transparent);
if (pixels)
ConvertImage(w, h, pixels, transparent);

CheckPixels(flags);
}
Expand Down

0 comments on commit 329da6d

Please sign in to comment.