1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
$NetBSD: patch-ap,v 1.1 2005/08/29 10:50:57 rillig Exp $
ISO C90 compatibility mode.
--- src/px/IMG_SavePNG.c.orig Thu Dec 30 14:21:11 2004
+++ src/px/IMG_SavePNG.c Mon Aug 29 12:26:59 2005
@@ -63,10 +63,11 @@ int IMG_SavePNG_RW(SDL_Surface *face, SD
rmask, gmask, bmask, amask);
if (surface) {
+ png_structp png_ptr;
SDL_BlitSurface(face, NULL, surface, NULL);
SDL_LockSurface(surface);
- png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, png_user_error, png_user_warn);
+ png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, png_user_error, png_user_warn);
if (!png_ptr) {
IMG_SetError("Couldn't allocate memory for PNG file");
}
@@ -84,6 +85,8 @@ int IMG_SavePNG_RW(SDL_Surface *face, SD
IMG_SetError("Error writing the PNG file");
}
else {
+ int colortype;
+
png_set_write_fn(png_ptr, src, png_write_data, png_io_flush);
/* Set the image information here. Width and height are up to 2^31,
* bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on
@@ -93,7 +96,7 @@ int IMG_SavePNG_RW(SDL_Surface *face, SD
* PNG_INTERLACE_ADAM7, and the compression_type and filter_type MUST
* currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE. REQUIRED
*/
- int colortype = png_colortype_from_surface(surface);
+ colortype = png_colortype_from_surface(surface);
png_set_IHDR(png_ptr, info_ptr, surface->w, surface->h, 8,
colortype, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|