diff options
author | Björn Steinbrink <B.Steinbrink@gmx.de> | 2005-09-18 11:01:39 +0000 |
---|---|---|
committer | Björn Steinbrink <B.Steinbrink@gmx.de> | 2005-09-18 11:01:39 +0000 |
commit | 7329e1e48c9366695121eb32a18eecd91846354b (patch) | |
tree | cf95ea9c6f12d98b032d03cbda7cee8d13d0eb8a | |
parent | 8efaed5076ec07e720380d61c70b6827b93a8fc7 (diff) | |
download | mana-client-7329e1e48c9366695121eb32a18eecd91846354b.tar.gz mana-client-7329e1e48c9366695121eb32a18eecd91846354b.tar.bz2 mana-client-7329e1e48c9366695121eb32a18eecd91846354b.tar.xz mana-client-7329e1e48c9366695121eb32a18eecd91846354b.zip |
Small cleanups.
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | src/resources/imagewriter.cpp | 9 |
2 files changed, 7 insertions, 3 deletions
@@ -17,6 +17,7 @@ 2005-09-18 Björn Steinbrink <B.Steinbrink@gmx.de> + * src/resources/imagewriter.cpp: Small cleanups. * src/Makefile.am, src/game.cpp, src/graphics.cpp, src/graphics.h, src/openglgraphics.cpp, src/openglgraphics.h: Changed saveScreenshot function in Graphics to getScreenshot. We now use the ImageWriter to diff --git a/src/resources/imagewriter.cpp b/src/resources/imagewriter.cpp index 98219e44..7cfa16b4 100644 --- a/src/resources/imagewriter.cpp +++ b/src/resources/imagewriter.cpp @@ -83,7 +83,7 @@ bool ImageWriter::writePNG(SDL_Surface *surface, png_set_packing(png_ptr); - row_pointers = (png_bytep*) malloc(sizeof(png_bytep)*surface->h); + row_pointers = new png_bytep[surface->h]; if (!row_pointers) { logger->log("Had trouble converting surface to row pointers"); @@ -91,19 +91,22 @@ bool ImageWriter::writePNG(SDL_Surface *surface, } for (int i = 0; i < surface->h; i++) + { row_pointers[i] = (png_bytep)(Uint8 *)surface->pixels + i * surface->pitch; + } png_write_image(png_ptr, row_pointers); png_write_end(png_ptr, info_ptr); + fclose(fp); - if (row_pointers) free(row_pointers); - if (info_ptr->palette) free(info_ptr->palette); + delete [] row_pointers; png_destroy_write_struct(&png_ptr, (png_infopp)NULL); if (SDL_MUSTLOCK(surface)) { SDL_UnlockSurface(surface); } + return true; } |