X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=image_png.c;h=d9d7a5004f844dfe13aacdfc444493507b56e6d4;hb=a19dce25671ecfa28e4eb3861f8636750bf3ba68;hp=19304fbcf91256cbd0a60cbfc1bc197c4a612b14;hpb=49a2165b5ff404125d2c7ab1a13a68cfc55d48ec;p=xonotic%2Fdarkplaces.git diff --git a/image_png.c b/image_png.c index 19304fbc..d9d7a500 100644 --- a/image_png.c +++ b/image_png.c @@ -111,6 +111,7 @@ qboolean PNG_OpenLibrary (void) "libpng12.0.dylib", #else "libpng12.so.0", + "libpng.so", // FreeBSD #endif NULL }; @@ -170,7 +171,7 @@ void PNG_CloseLibrary (void) #define PNG_INFO_tRNS 0x0010 // this struct is only used for status information during loading -struct +static struct { const unsigned char *tmpBuf; int tmpBuflength; @@ -204,15 +205,15 @@ void PNG_fReadData(void *png, unsigned char *data, size_t length) l = my_png.tmpBuflength - my_png.tmpi; if (l < length) { - Con_Printf("PNG_fReadData: overrun by %i bytes\n", length - l); + Con_Printf("PNG_fReadData: overrun by %i bytes\n", (int)(length - l)); // a read going past the end of the file, fill in the remaining bytes // with 0 just to be consistent memset(data + l, 0, length - l); length = l; } memcpy(data, my_png.tmpBuf + my_png.tmpi, length); - my_png.tmpi += length; - Com_HexDumpToConsole(data, length); + my_png.tmpi += (int)length; + //Com_HexDumpToConsole(data, (int)length); } void PNG_error_fn(void *png, const char *message) @@ -243,13 +244,21 @@ unsigned char *PNG_LoadImage (const unsigned char *raw, int filesize, int matchw if(qpng_sig_cmp(raw, 0, filesize)) return NULL; - png = qpng_create_read_struct(PNG_LIBPNG_VER_STRING, 0, PNG_error_fn, PNG_warning_fn); + png = (void *)qpng_create_read_struct(PNG_LIBPNG_VER_STRING, 0, (void *)PNG_error_fn, (void *)PNG_warning_fn); if(!png) return NULL; // NOTE: this relies on jmp_buf being the first thing in the png structure // created by libpng! (this is correct for libpng 1.2.x) +#ifdef __cplusplus +#ifdef MACOSX + if (setjmp((int *)png)) +#else + if (setjmp((__jmp_buf_tag *)png)) +#endif +#else if (setjmp(png)) +#endif { qpng_destroy_read_struct(&png, &pnginfo, 0); return NULL; @@ -276,7 +285,7 @@ unsigned char *PNG_LoadImage (const unsigned char *raw, int filesize, int matchw //my_png.Interlace = 0; //my_png.Compression = 0; //my_png.Filter = 0; - qpng_set_read_fn(png, ioBuffer, PNG_fReadData); + qpng_set_read_fn(png, ioBuffer, (void *)PNG_fReadData); qpng_read_info(png, pnginfo); qpng_get_IHDR(png, pnginfo, &my_png.Width, &my_png.Height,&my_png.BitDepth, &my_png.ColorType, &my_png.Interlace, &my_png.Compression, &my_png.Filter); if ((matchwidth && my_png.Width != (unsigned int)matchwidth) || (matchheight && my_png.Height != (unsigned int)matchheight)) @@ -307,10 +316,10 @@ unsigned char *PNG_LoadImage (const unsigned char *raw, int filesize, int matchw my_png.FRowBytes = qpng_get_rowbytes(png, pnginfo); my_png.BytesPerPixel = qpng_get_channels(png, pnginfo); - my_png.FRowPtrs = Mem_Alloc(tempmempool, my_png.Height * sizeof(*my_png.FRowPtrs)); + my_png.FRowPtrs = (unsigned char **)Mem_Alloc(tempmempool, my_png.Height * sizeof(*my_png.FRowPtrs)); if (my_png.FRowPtrs) { - my_png.Data = Mem_Alloc(tempmempool, my_png.Height * my_png.FRowBytes); + my_png.Data = (unsigned char *)Mem_Alloc(tempmempool, my_png.Height * my_png.FRowBytes); if(my_png.Data) { for(y = 0;y < my_png.Height;y++)