Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-08-23 19:27:10 +0000
committerStijn Buys <ingar@osirion.org>2008-08-23 19:27:10 +0000
commit184598a43548642b9a4bfe8c2fce58e4a966d0bb (patch)
tree636e7c977d7e93390327da3be060f9c92adefc01 /src/render
parent37bfbfbd234cce09b67c1d53e1ef7d91a46e53cc (diff)
instant r_fullscreen switching, bound to alt+enter
Diffstat (limited to 'src/render')
-rw-r--r--src/render/pngfile.cc15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/render/pngfile.cc b/src/render/pngfile.cc
index 27cfd8f..8038d22 100644
--- a/src/render/pngfile.cc
+++ b/src/render/pngfile.cc
@@ -60,11 +60,13 @@ Image *PNG::load(const char *filename)
if (!info_ptr) {
con_warn << "Error reading " << filename << ": png_create_info_struct failed!" << std::endl;
filesystem::close(png_file);
+ png_destroy_read_struct(&png_ptr, 0, 0);
return 0;
}
if (setjmp(png_jmpbuf(png_ptr))) {
con_warn << "Error reading " << filename << ": error during init_io!" << std::endl;
filesystem::close(png_file);
+ png_destroy_read_struct(&png_ptr, &info_ptr, 0);
return 0;
}
@@ -86,6 +88,7 @@ Image *PNG::load(const char *filename)
if (png_depth != 8) {
con_warn << "Error reading " << filename << ": bits per channel must be 8!" << std::endl;
filesystem::close(png_file);
+ png_destroy_read_struct(&png_ptr, &info_ptr, 0);
return 0;
}
@@ -97,6 +100,7 @@ Image *PNG::load(const char *filename)
con_warn << "Error reading " << filename << std::endl;
filesystem::close(png_file);
delete image;
+ png_destroy_read_struct(&png_ptr, &info_ptr, 0);
return 0;
}
@@ -111,6 +115,8 @@ Image *PNG::load(const char *filename)
con_debug << " " << filename << " " << png_width << "x" << png_height << "x" << channels * png_depth << "bpp" << std::endl;
+ png_destroy_read_struct(&png_ptr, &info_ptr, 0);
+
return image;
}
@@ -123,7 +129,6 @@ void PNG::save(const char *filename, Image & image)
return;
}
- /* initialize stuff */
png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!png_ptr) {
fclose(png_file);
@@ -133,14 +138,16 @@ void PNG::save(const char *filename, Image & image)
png_infop info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr) {
- fclose(png_file);
con_warn << "Error writing " << filename << ": png_create_info_struct failed!" << std::endl;
+ fclose(png_file);
+ png_destroy_write_struct(&png_ptr, 0);
return;
}
if (setjmp(png_jmpbuf(png_ptr))) {
con_warn << "Error reading " << filename << ": error during init_io!" << std::endl;
fclose(png_file);
+ png_destroy_write_struct(&png_ptr, &info_ptr);
return;
}
@@ -150,6 +157,7 @@ void PNG::save(const char *filename, Image & image)
if (setjmp(png_jmpbuf(png_ptr))) {
con_warn << "Error writing " << filename << ": error writing header!" << std::endl;
fclose(png_file);
+ png_destroy_write_struct(&png_ptr, &info_ptr);
return;
}
@@ -162,6 +170,7 @@ void PNG::save(const char *filename, Image & image)
if (setjmp(png_jmpbuf(png_ptr))) {
con_warn << "Error writing " << filename << ": error writing header!" << std::endl;
fclose(png_file);
+ png_destroy_write_struct(&png_ptr, &info_ptr);
return;
}
@@ -176,12 +185,14 @@ void PNG::save(const char *filename, Image & image)
if (setjmp(png_jmpbuf(png_ptr))) {
con_warn << "Error writing " << filename << std::endl;
fclose(png_file);
+ png_destroy_write_struct(&png_ptr, &info_ptr);
return;
}
png_write_end(png_ptr, NULL);
fclose(png_file);
+ png_destroy_write_struct(&png_ptr, &info_ptr);
con_print << "Wrote " << filename << std::endl;
}