summaryrefslogtreecommitdiff
path: root/src/resources/imagewriter.cpp
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2005-09-18 11:01:39 +0000
committerBjörn Steinbrink <B.Steinbrink@gmx.de>2005-09-18 11:01:39 +0000
commit7329e1e48c9366695121eb32a18eecd91846354b (patch)
treecf95ea9c6f12d98b032d03cbda7cee8d13d0eb8a /src/resources/imagewriter.cpp
parent8efaed5076ec07e720380d61c70b6827b93a8fc7 (diff)
downloadmana-7329e1e48c9366695121eb32a18eecd91846354b.tar.gz
mana-7329e1e48c9366695121eb32a18eecd91846354b.tar.bz2
mana-7329e1e48c9366695121eb32a18eecd91846354b.tar.xz
mana-7329e1e48c9366695121eb32a18eecd91846354b.zip
Small cleanups.
Diffstat (limited to 'src/resources/imagewriter.cpp')
-rw-r--r--src/resources/imagewriter.cpp9
1 files changed, 6 insertions, 3 deletions
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;
}