propagate png compatibility fix

This commit is contained in:
Timothee 'TTimo' Besset 2012-06-30 17:39:21 -05:00
parent 3dd08a4604
commit f3fb7465da

View file

@ -98,8 +98,7 @@ typedef struct pngBuffer_s
{ {
byte *buffer; byte *buffer;
int size, offset; int size, offset;
} } pngBuffer_t;
pngBuffer_t;
void PNGReadData( png_struct *png, png_byte *buffer, png_size_t size ){ void PNGReadData( png_struct *png, png_byte *buffer, png_size_t size ){
pngBuffer_t *pb = (pngBuffer_t*) png_get_io_ptr( png ); pngBuffer_t *pb = (pngBuffer_t*) png_get_io_ptr( png );
@ -123,12 +122,11 @@ void PNGReadData( png_struct *png, png_byte *buffer, png_size_t size ){
static void LoadPNGBuffer( byte *buffer, int size, byte **pixels, int *width, int *height ){ static void LoadPNGBuffer( byte *buffer, int size, byte **pixels, int *width, int *height ){
png_struct *png; png_struct *png;
png_info *info, *end; png_info *info, *end;
pngBuffer_t pb; pngBuffer_t pb;
int i, bitDepth, colorType, channels; int i, bitDepth, colorType, channels;
png_uint_32 w, h; png_uint_32 w, h;
byte **rowPointers; byte **rowPointers;
/* dummy check */ /* dummy check */
if ( buffer == NULL || size <= 0 || pixels == NULL || width == NULL || height == NULL ) { if ( buffer == NULL || size <= 0 || pixels == NULL || width == NULL || height == NULL ) {
return; return;
@ -167,14 +165,13 @@ static void LoadPNGBuffer( byte *buffer, int size, byte **pixels, int *width, in
} }
/* set read callback */ /* set read callback */
pb.buffer = buffer; pb.buffer = buffer;
pb.size = size; pb.size = size;
pb.offset = 0; pb.offset = 0;
png_set_read_fn( png, &pb, PNGReadData ); png_set_read_fn( png, (void*)&pb, PNGReadData );
png->io_ptr = &pb; /* hack! */
/* set error longjmp */ /* set error longjmp */
if ( setjmp( png->jmpbuf ) ) { if ( setjmp( png_jmpbuf(png) ) ) {
Sys_Printf( "WARNING: An error occurred reading PNG image\n" ); Sys_Printf( "WARNING: An error occurred reading PNG image\n" );
png_destroy_read_struct( &png, &info, &end ); png_destroy_read_struct( &png, &info, &end );
return; return;