This should fix the problem with PNG files on Win32
The reason this patch works is that SDL and PNG should use the same rules
for allocating the pitch of a surface. Let me know ASAP if this doesn’t
work for any of the images you use!
I’m going to test the install problems on SuSE, and apply this patch
tomorrow, for a 1.0.5 release.
See ya!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software
-------------- next part --------------
— SDL_image-1.0.4/IMG_png.c Wed Jan 19 23:06:52 2000
+++ SDL_image-1.0.4.new/IMG_png.c Wed Apr 12 00:12:49 2000
@@ -199,21 +199,25 @@
Amask = 0x000000FF;
}
}
- surface = SDL_AllocSurface(SDL_SWSURFACE, 0, 0,
- surface = SDL_AllocSurface(SDL_SWSURFACE, width, height,
bit_depth*info_ptr->channels, Rmask,Gmask,Bmask,Amask);
if ( surface == NULL ) {
IMG_SetError(“Out of memory”);
goto done;
}
- surface->w = width;
- surface->h = height;
- surface->pitch = png_get_rowbytes(png_ptr, info_ptr);
- surface->pixels = malloc(surface->h*surface->pitch);
-
if ( surface->pitch != png_get_rowbytes(png_ptr, info_ptr) ) {
-
IMG_SetError("SDL pitch didn't match PNG pitch");
-
SDL_FreeSurface(surface);
-
surface = NULL;
-
goto done;
-
}
/* Create the array of pointers to image data /
row_pointers = (png_bytep) malloc(sizeof(png_bytep)*height);
- if ( (surface->pixels == NULL) || (row_pointers == NULL) ) {
- if ( (row_pointers == NULL) ) {
IMG_SetError(“Out of memory”); -
SDL_FreeSurface(surface);
-
}surface = NULL; goto done;
for (row = 0; row < height; row++) {