Репозитории ALT
Группа :: Графика
Пакет: enblend
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: enblend-fix-png15-4.0.patch
Скачать
Скачать
diff -Naur enblend-4.0.sav/src/vigra_impex/png.cxx enblend-4.0/src/vigra_impex/png.cxx
--- enblend-4.0.sav/src/vigra_impex/png.cxx 2011-04-08 22:56:41.000000000 +0400
+++ enblend-4.0/src/vigra_impex/png.cxx 2012-09-22 20:40:11.875811835 +0400
@@ -50,6 +50,15 @@
#ifdef HasPNG
+extern "C"
+{
+#include <png.h>
+}
+
+#if PNG_LIBPNG_VER < 10201
+#error "please update your libpng to at least 1.2.1"
+#endif
+
#include "vigra/config.hxx"
#include "vigra/sized_int.hxx"
#include "void_vector.hxx"
@@ -60,15 +69,6 @@
#include <stdexcept>
#include <iostream>
-extern "C"
-{
-#include <png.h>
-}
-
-#if PNG_LIBPNG_VER < 10201
-#error "please update your libpng to at least 1.2.1"
-#endif
-
// TODO: per-scanline reading/writing
namespace {
@@ -81,7 +81,11 @@
static void PngError( png_structp png_ptr, png_const_charp error_msg )
{
png_error_message = std::string(error_msg);
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
+ longjmp( png_jmpbuf(png_ptr), 1 );
+#else
longjmp( png_ptr->jmpbuf, 1 );
+#endif
}
// called on non-fatal errors
@@ -213,7 +217,11 @@
vigra_postcondition( png != 0, "could not create the read struct." );
// create info struct
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
+ if (setjmp(png_jmpbuf(png))) {
+#else
if (setjmp(png->jmpbuf)) {
+#endif
png_destroy_read_struct( &png, &info, NULL );
vigra_postcondition( false, png_error_message.insert(0, "error in png_create_info_struct(): ").c_str() );
}
@@ -221,14 +229,22 @@
vigra_postcondition( info != 0, "could not create the info struct." );
// init png i/o
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
+ if (setjmp(png_jmpbuf(png))) {
+#else
if (setjmp(png->jmpbuf)) {
+#endif
png_destroy_read_struct( &png, &info, NULL );
vigra_postcondition( false, png_error_message.insert(0, "error in png_init_io(): ").c_str() );
}
png_init_io( png, file.get() );
// specify that the signature was already read
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
+ if (setjmp(png_jmpbuf(png))) {
+#else
if (setjmp(png->jmpbuf)) {
+#endif
png_destroy_read_struct( &png, &info, NULL );
vigra_postcondition( false, png_error_message.insert(0, "error in png_set_sig_bytes(): ").c_str() );
}
@@ -244,13 +260,21 @@
void PngDecoderImpl::init()
{
// read all chunks up to the image data
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
+ if (setjmp(png_jmpbuf(png)))
+#else
if (setjmp(png->jmpbuf))
+#endif
vigra_postcondition( false, png_error_message.insert(0, "error in png_read_info(): ").c_str() );
png_read_info( png, info );
// pull over the header fields
int interlace_method, compression_method, filter_method;
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
+ if (setjmp(png_jmpbuf(png)))
+#else
if (setjmp(png->jmpbuf))
+#endif
vigra_postcondition( false, png_error_message.insert(0, "error in png_get_IHDR(): ").c_str() );
png_get_IHDR( png, info, &width, &height, &bit_depth, &color_type,
&interlace_method, &compression_method, &filter_method );
@@ -264,7 +288,11 @@
// transform palette to rgb
if ( color_type == PNG_COLOR_TYPE_PALETTE) {
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
+ if (setjmp(png_jmpbuf(png)))
+#else
if (setjmp(png->jmpbuf))
+#endif
vigra_postcondition( false, png_error_message.insert(0, "error in png_palette_to_rgb(): ").c_str() );
png_set_palette_to_rgb(png);
color_type = PNG_COLOR_TYPE_RGB;
@@ -273,9 +301,15 @@
// expand gray values to at least one byte size
if ( color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8 ) {
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
+ if (setjmp(png_jmpbuf(png)))
+ vigra_postcondition( false,png_error_message.insert(0, "error in png_set_expand_gray_1_2_4_to_8(): ").c_str());
+ png_set_expand_gray_1_2_4_to_8(png);
+#else
if (setjmp(png->jmpbuf))
vigra_postcondition( false,png_error_message.insert(0, "error in png_set_gray_1_2_4_to_8(): ").c_str());
png_set_gray_1_2_4_to_8(png);
+#endif
bit_depth = 8;
}
@@ -283,7 +317,11 @@
#if 0
// strip alpha channel
if ( color_type & PNG_COLOR_MASK_ALPHA ) {
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
+ if (setjmp(png_jmpbuf(png)))
+#else
if (setjmp(png->jmpbuf))
+#endif
vigra_postcondition( false, png_error_message.insert(0, "error in png_set_strip_alpha(): ").c_str() );
png_set_strip_alpha(png);
color_type ^= PNG_COLOR_MASK_ALPHA;
@@ -325,9 +363,17 @@
#if (PNG_LIBPNG_VER > 10008) && defined(PNG_READ_iCCP_SUPPORTED)
char * dummyName;
int dummyCompType;
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
+ unsigned char * profilePtr;
+#else
char * profilePtr;
+#endif
png_uint_32 profileLen;
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
+ if (png_get_valid(png, info, PNG_INFO_iCCP)) {
+#else
if (info->valid & PNG_INFO_iCCP) {
+#endif
png_get_iCCP(png, info, &dummyName, &dummyCompType, &profilePtr, &profileLen) ;
iccProfilePtr = (unsigned char *) profilePtr;
iccProfileLength = profileLen;
@@ -340,7 +386,11 @@
// image gamma
double image_gamma = 0.45455;
if ( png_get_valid( png, info, PNG_INFO_gAMA ) ) {
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
+ if (setjmp(png_jmpbuf(png)))
+#else
if (setjmp(png->jmpbuf))
+#endif
vigra_postcondition( false, png_error_message.insert(0, "error in png_get_gAMA(): ").c_str() );
png_get_gAMA( png, info, &image_gamma );
}
@@ -349,26 +399,46 @@
double screen_gamma = 2.2;
// set gamma correction
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
+ if (setjmp(png_jmpbuf(png)))
+#else
if (setjmp(png->jmpbuf))
+#endif
vigra_postcondition( false, png_error_message.insert(0, "error in png_set_gamma(): ").c_str() );
png_set_gamma( png, screen_gamma, image_gamma );
#endif
// interlace handling, get number of read passes needed
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
+ if (setjmp(png_jmpbuf(png)))
+#else
if (setjmp(png->jmpbuf))
+#endif
vigra_postcondition( false,png_error_message.insert(0, "error in png_set_interlace_handling(): ").c_str());
n_interlace_passes = png_set_interlace_handling(png);
// update png library state to reflect any changes that were made
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
+ if (setjmp(png_jmpbuf(png)))
+#else
if (setjmp(png->jmpbuf))
+#endif
vigra_postcondition( false, png_error_message.insert(0, "error in png_read_update_info(): ").c_str() );
png_read_update_info( png, info );
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
+ if (setjmp(png_jmpbuf(png)))
+#else
if (setjmp(png->jmpbuf))
+#endif
vigra_postcondition( false,png_error_message.insert(0, "error in png_get_channels(): ").c_str());
n_channels = png_get_channels(png, info);
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
+ if (setjmp(png_jmpbuf(png)))
+#else
if (setjmp(png->jmpbuf))
+#endif
vigra_postcondition( false,png_error_message.insert(0, "error in png_get_rowbytes(): ").c_str());
rowsize = png_get_rowbytes(png, info);
@@ -379,7 +449,11 @@
void PngDecoderImpl::nextScanline()
{
for (int i=0; i < n_interlace_passes; i++) {
- if (setjmp(png->jmpbuf))
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
+ if (setjmp(png_jmpbuf(png)))
+#else
+ if (setjmp(png->jmpbuf))
+#endif
vigra_postcondition( false,png_error_message.insert(0, "error in png_read_row(): ").c_str());
png_read_row(png, row_data.begin(), NULL);
}
@@ -545,7 +619,11 @@
vigra_postcondition( png != 0, "could not create the write struct." );
// create info struct
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
+ if (setjmp(png_jmpbuf(png))) {
+#else
if (setjmp(png->jmpbuf)) {
+#endif
png_destroy_write_struct( &png, &info );
vigra_postcondition( false, png_error_message.insert(0, "error in png_info_struct(): ").c_str() );
}
@@ -556,7 +634,11 @@
}
// init png i/o
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
+ if (setjmp(png_jmpbuf(png))) {
+#else
if (setjmp(png->jmpbuf)) {
+#endif
png_destroy_write_struct( &png, &info );
vigra_postcondition( false, png_error_message.insert(0, "error in png_init_io(): ").c_str() );
}
@@ -571,7 +653,11 @@
void PngEncoderImpl::finalize()
{
// write the IHDR
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
+ if (setjmp(png_jmpbuf(png)))
+#else
if (setjmp(png->jmpbuf))
+#endif
vigra_postcondition( false, png_error_message.insert(0, "error in png_set_IHDR(): ").c_str() );
png_set_IHDR( png, info, width, height, bit_depth, color_type,
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT,
@@ -579,7 +665,11 @@
// set resolution
if (x_resolution > 0 && y_resolution > 0) {
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
+ if (setjmp(png_jmpbuf(png)))
+#else
if (setjmp(png->jmpbuf))
+#endif
vigra_postcondition( false, png_error_message.insert(0, "error in png_set_pHYs(): ").c_str() );
png_set_pHYs(png, info, (png_uint_32) (x_resolution / 0.0254 + 0.5),
(png_uint_32) (y_resolution / 0.0254 + 0.5),
@@ -588,7 +678,11 @@
// set offset
if (position.x > 0 && position.y > 0) {
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
+ if (setjmp(png_jmpbuf(png)))
+#else
if (setjmp(png->jmpbuf))
+#endif
vigra_postcondition( false, png_error_message.insert(0, "error in png_set_oFFs(): ").c_str() );
png_set_oFFs(png, info, position.x, position.y, PNG_OFFSET_PIXEL);
}
@@ -597,12 +691,20 @@
// set icc profile
if (iccProfile.size() > 0) {
png_set_iCCP(png, info, "icc", 0,
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
+ (unsigned char *)iccProfile.begin(), iccProfile.size());
+#else
(char *)iccProfile.begin(), iccProfile.size());
+#endif
}
#endif
// write the info struct
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
+ if (setjmp(png_jmpbuf(png)))
+#else
if (setjmp(png->jmpbuf))
+#endif
vigra_postcondition( false, png_error_message.insert(0, "error in png_write_info(): ").c_str() );
png_write_info( png, info );
@@ -634,10 +736,18 @@
}
// write the whole image
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
+ if (setjmp(png_jmpbuf(png)))
+#else
if (setjmp(png->jmpbuf))
+#endif
vigra_postcondition( false, png_error_message.insert(0, "error in png_write_image(): ").c_str() );
png_write_image( png, row_pointers.begin() );
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
+ if (setjmp(png_jmpbuf(png)))
+#else
if (setjmp(png->jmpbuf))
+#endif
vigra_postcondition( false, png_error_message.insert(0, "error in png_write_end(): ").c_str() );
png_write_end(png, info);
}