Fix compatibility warnings of libpng v1.4. Hopefully maintained compatibility with older versions... please report if problems.
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1504 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
0ab3678768
commit
85e4ea9a79
@ -125,7 +125,7 @@ Zlib:
|
|||||||
Libpng
|
Libpng
|
||||||
Requires: Zlib
|
Requires: Zlib
|
||||||
http://www.mirrorservice.org/sites/download.sourceforge.net/pub/sourceforge/l/li/libpng/
|
http://www.mirrorservice.org/sites/download.sourceforge.net/pub/sourceforge/l/li/libpng/
|
||||||
libpng-1.0.23.tar.gz
|
libpng-1.4.2.tar.gz (Before June 2010, we were using libpng-1.0.23.tar.gz)
|
||||||
Uncompress in temporary directory
|
Uncompress in temporary directory
|
||||||
./configure
|
./configure
|
||||||
make
|
make
|
||||||
|
|||||||
@ -27,6 +27,19 @@
|
|||||||
|
|
||||||
#ifndef __no_pnglib__
|
#ifndef __no_pnglib__
|
||||||
#include <png.h>
|
#include <png.h>
|
||||||
|
#if (PNG_LIBPNG_VER_MAJOR <= 1) && (PNG_LIBPNG_VER_MINOR < 4)
|
||||||
|
// Compatibility layer to allow us to use libng 1.4 or any older one.
|
||||||
|
|
||||||
|
// This function is renamed in 1.4
|
||||||
|
#define png_set_expand_gray_1_2_4_to_8(x) png_set_gray_1_2_4_to_8(x)
|
||||||
|
|
||||||
|
// Wrappers that are mandatory in 1.4. Older version allowed direct access.
|
||||||
|
#define png_get_rowbytes(png_ptr,info_ptr) ((info_ptr)->rowbytes)
|
||||||
|
#define png_get_image_width(png_ptr,info_ptr) ((info_ptr)->width)
|
||||||
|
#define png_get_image_height(png_ptr,info_ptr) ((info_ptr)->height)
|
||||||
|
#define png_get_bit_depth(png_ptr,info_ptr) ((info_ptr)->bit_depth)
|
||||||
|
#define png_get_color_type(png_ptr,info_ptr) ((info_ptr)->color_type)
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -3371,8 +3384,8 @@ void Load_PNG(T_IO_Context * context)
|
|||||||
|
|
||||||
// Load file information
|
// Load file information
|
||||||
png_read_info(png_ptr, info_ptr);
|
png_read_info(png_ptr, info_ptr);
|
||||||
color_type = info_ptr->color_type;
|
color_type = png_get_color_type(png_ptr,info_ptr);
|
||||||
bit_depth = info_ptr->bit_depth;
|
bit_depth = png_get_bit_depth(png_ptr,info_ptr);
|
||||||
|
|
||||||
// If it's any supported file
|
// If it's any supported file
|
||||||
// (Note: As of writing this, this test covers every possible
|
// (Note: As of writing this, this test covers every possible
|
||||||
@ -3425,9 +3438,9 @@ void Load_PNG(T_IO_Context * context)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (color_type == PNG_COLOR_TYPE_RGB || color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
if (color_type == PNG_COLOR_TYPE_RGB || color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||||
Pre_load(context,info_ptr->width,info_ptr->height,File_length_file(file),FORMAT_PNG,PIXEL_SIMPLE,1);
|
Pre_load(context,png_get_image_width(png_ptr,info_ptr),png_get_image_height(png_ptr,info_ptr),File_length_file(file),FORMAT_PNG,PIXEL_SIMPLE,1);
|
||||||
else
|
else
|
||||||
Pre_load(context, info_ptr->width,info_ptr->height,File_length_file(file),FORMAT_PNG,context->Ratio,0);
|
Pre_load(context,png_get_image_width(png_ptr,info_ptr),png_get_image_height(png_ptr,info_ptr),File_length_file(file),FORMAT_PNG,context->Ratio,0);
|
||||||
|
|
||||||
if (File_error==0)
|
if (File_error==0)
|
||||||
{
|
{
|
||||||
@ -3535,8 +3548,8 @@ void Load_PNG(T_IO_Context * context)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
context->Width=info_ptr->width;
|
context->Width=png_get_image_width(png_ptr,info_ptr);
|
||||||
context->Height=info_ptr->height;
|
context->Height=png_get_image_height(png_ptr,info_ptr);
|
||||||
|
|
||||||
png_set_interlace_handling(png_ptr);
|
png_set_interlace_handling(png_ptr);
|
||||||
png_read_update_info(png_ptr, info_ptr);
|
png_read_update_info(png_ptr, info_ptr);
|
||||||
@ -3556,7 +3569,7 @@ void Load_PNG(T_IO_Context * context)
|
|||||||
// 8bpp
|
// 8bpp
|
||||||
|
|
||||||
for (y=0; y<context->Height; y++)
|
for (y=0; y<context->Height; y++)
|
||||||
Row_pointers[y] = (png_byte*) malloc(info_ptr->rowbytes);
|
Row_pointers[y] = (png_byte*) malloc(png_get_rowbytes(png_ptr,info_ptr));
|
||||||
row_pointers_allocated = 1;
|
row_pointers_allocated = 1;
|
||||||
|
|
||||||
png_read_image(png_ptr, Row_pointers);
|
png_read_image(png_ptr, Row_pointers);
|
||||||
@ -3575,7 +3588,7 @@ void Load_PNG(T_IO_Context * context)
|
|||||||
// It's a preview
|
// It's a preview
|
||||||
// Unfortunately we need to allocate loads of memory
|
// Unfortunately we need to allocate loads of memory
|
||||||
for (y=0; y<context->Height; y++)
|
for (y=0; y<context->Height; y++)
|
||||||
Row_pointers[y] = (png_byte*) malloc(info_ptr->rowbytes);
|
Row_pointers[y] = (png_byte*) malloc(png_get_rowbytes(png_ptr,info_ptr));
|
||||||
row_pointers_allocated = 1;
|
row_pointers_allocated = 1;
|
||||||
|
|
||||||
png_read_image(png_ptr, Row_pointers);
|
png_read_image(png_ptr, Row_pointers);
|
||||||
@ -3674,9 +3687,15 @@ void Save_PNG(T_IO_Context * context)
|
|||||||
{
|
{
|
||||||
// Commentaires texte PNG
|
// Commentaires texte PNG
|
||||||
// Cette partie est optionnelle
|
// Cette partie est optionnelle
|
||||||
png_text text_ptr[2] = {
|
#ifdef PNG_iTXt_SUPPORTED
|
||||||
{-1, "Software", "Grafx2", 6},
|
png_text text_ptr[2] = {
|
||||||
{-1, "Title", NULL, 0}
|
{-1, "Software", "Grafx2", 6, 0, NULL, NULL},
|
||||||
|
{-1, "Title", NULL, 0, 0, NULL, NULL}
|
||||||
|
#else
|
||||||
|
png_text text_ptr[2] = {
|
||||||
|
{-1, "Software", "Grafx2", 6},
|
||||||
|
{-1, "Title", NULL, 0}
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
int nb_text_chunks=1;
|
int nb_text_chunks=1;
|
||||||
if (context->Comment[0])
|
if (context->Comment[0])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user