diff options
author | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_fr> | 2010-05-22 15:57:21 +0200 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_fr> | 2010-05-27 02:21:40 +0200 |
commit | ad34e7cf98b7a4d7096b66c743e4a087d9b432dd (patch) | |
tree | db3cee9dff3847c9f424c9fa8761e9f1e27d19d2 /tools/dyecmd/src/imagewriter.cpp | |
parent | 5497d10b008bfed6b1aee8aac23fe640faebf1ad (diff) | |
download | mana-client-ad34e7cf98b7a4d7096b66c743e4a087d9b432dd.tar.gz mana-client-ad34e7cf98b7a4d7096b66c743e4a087d9b432dd.tar.bz2 mana-client-ad34e7cf98b7a4d7096b66c743e4a087d9b432dd.tar.xz mana-client-ad34e7cf98b7a4d7096b66c743e4a087d9b432dd.zip |
Basically rewrote a big part of the dyecmd tool.
The tool should be fine now, but some testing on mac would be appreciated.
Mainly removed all the program exits using exception, try catch, etc...
I found them rather irrelevant, creating memleaks, while not returning
information about the error in some case.
Reviewed-by: Jaxad0127
Diffstat (limited to 'tools/dyecmd/src/imagewriter.cpp')
-rwxr-xr-x[-rw-r--r--] | tools/dyecmd/src/imagewriter.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/tools/dyecmd/src/imagewriter.cpp b/tools/dyecmd/src/imagewriter.cpp index 669b3567..d237abbf 100644..100755 --- a/tools/dyecmd/src/imagewriter.cpp +++ b/tools/dyecmd/src/imagewriter.cpp @@ -22,6 +22,7 @@ #include "imagewriter.h" #include <png.h> +#include <iostream> #include <string> #include <SDL/SDL.h> @@ -32,8 +33,8 @@ bool ImageWriter::writePNG(SDL_Surface *surface, FILE *fp = fopen(filename.c_str(), "wb"); if (!fp) { - // todo - // logger->log("could not open file %s for writing", filename.c_str()); + std::cout << "PNG writer: Could not open file for writing: " + << filename << std::endl; return false; } @@ -49,8 +50,8 @@ bool ImageWriter::writePNG(SDL_Surface *surface, png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0); if (!png_ptr) { - // todo - // logger->log("Had trouble creating png_structp"); + std::cout << "PNG writer: Had trouble creating png_structp" + << std::endl; return false; } @@ -58,16 +59,15 @@ bool ImageWriter::writePNG(SDL_Surface *surface, if (!info_ptr) { png_destroy_write_struct(&png_ptr, (png_infopp)NULL); - // todo - // logger->log("Could not create png_info"); + std::cout << "PNG writer: Could not create png_info" << std::endl; return false; } if (setjmp(png_jmpbuf(png_ptr))) { png_destroy_write_struct(&png_ptr, (png_infopp)NULL); - // todo - // logger->log("problem writing to %s", filename.c_str()); + std::cout << "PNG writer: problem writing to : " + << filename << std::endl; return false; } @@ -86,8 +86,9 @@ bool ImageWriter::writePNG(SDL_Surface *surface, row_pointers = new png_bytep[surface->h]; if (!row_pointers) { - // todo - // logger->log("Had trouble converting surface to row pointers"); + std::cout + << "PNG writer: Had trouble converting surface to row pointers" + << std::endl; return false; } @@ -105,9 +106,8 @@ bool ImageWriter::writePNG(SDL_Surface *surface, png_destroy_write_struct(&png_ptr, (png_infopp)NULL); - if (SDL_MUSTLOCK(surface)) { + if (SDL_MUSTLOCK(surface)) SDL_UnlockSurface(surface); - } return true; } |