Properly support png 1.5

Obtained from:	Gentoo
This commit is contained in:
Baptiste Daroussin 2014-12-24 13:12:15 +00:00
parent bcdeb1b72b
commit d42a40daa3
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=375455
3 changed files with 45 additions and 20 deletions

View file

@ -16,7 +16,7 @@ BUILD_DEPENDS= swig:${PORTSDIR}/devel/swig13
LIB_DEPENDS= libagg.so:${PORTSDIR}/graphics/agg \
libjpeg.so:${PORTSDIR}/graphics/jpeg \
libtiff.so:${PORTSDIR}/graphics/tiff \
libpng15.so:${PORTSDIR}/graphics/png \
libpng.so:${PORTSDIR}/graphics/png \
libgif.so:${PORTSDIR}/graphics/giflib \
libjasper.so:${PORTSDIR}/graphics/jasper \
libIlmImf.so:${PORTSDIR}/graphics/OpenEXR \
@ -26,7 +26,7 @@ LIB_DEPENDS= libagg.so:${PORTSDIR}/graphics/agg \
#hack to get custom exactcode configure script to enable tiff support with
#broken headers on c++ in base system:
CPPFLAGS+= -fpermissive -I${LOCALBASE}/include -I${LOCALBASE}/include/libpng15
CPPFLAGS+= -fpermissive -I${LOCALBASE}/include
USES= gmake perl5 pkgconfig python tar:bzip2
USE_XORG= x11
HAS_CONFIGURE= yes

View file

@ -1,15 +1,6 @@
--- codecs/png.cc.orig 2010-03-03 22:04:44.000000000 +0100
+++ codecs/png.cc 2012-04-25 19:08:13.000000000 +0200
@@ -17,6 +17,8 @@
#include <stdlib.h>
#include <png.h>
+#include <zlib.h>
+#include <pngpriv.h>
#include <iostream>
@@ -71,7 +73,7 @@
--- codecs/png.cc
+++ codecs/png.cc
@@ -71,7 +71,7 @@
/* Allocate/initialize the memory for image information. REQUIRED. */
info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == NULL) {
@ -18,7 +9,7 @@
return 0;
}
@@ -82,7 +84,7 @@
@@ -82,7 +82,7 @@
if (setjmp(png_jmpbuf(png_ptr))) {
/* Free all of the memory associated with the png_ptr and info_ptr */
@ -27,7 +18,7 @@
/* If we get here, we had a problem reading the file */
return 0;
}
@@ -99,7 +101,7 @@
@@ -99,7 +99,7 @@
png_read_info (png_ptr, info_ptr);
png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
@ -36,7 +27,7 @@
image.w = width;
image.h = height;
@@ -132,7 +134,7 @@
@@ -132,7 +132,7 @@
#if 0 // no longer needed
/* Expand grayscale images to the full 8 bits from 2, or 4 bits/pixel */
if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth > 1 && bit_depth < 8) {
@ -45,7 +36,7 @@
image.bps = 8;
}
#endif
@@ -196,11 +198,11 @@
@@ -196,11 +196,11 @@
for (int pass = 0; pass < number_passes; ++pass)
for (unsigned int y = 0; y < height; ++y) {
row_pointers[0] = image.getRawData() + y * stride;
@ -59,7 +50,7 @@
/* that's it */
return true;
@@ -224,7 +226,7 @@
@@ -224,7 +224,7 @@
/* Allocate/initialize the memory for image information. REQUIRED. */
info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == NULL) {
@ -68,7 +59,7 @@
return false;
}
@@ -244,7 +246,6 @@
@@ -244,7 +244,6 @@
else if (quality > Z_BEST_COMPRESSION) quality = Z_BEST_COMPRESSION;
png_set_compression_level(png_ptr, quality);

View file

@ -0,0 +1,34 @@
--- codecs/png.cc
+++ codecs/png.cc
@@ -16,6 +16,7 @@
*/
#include <stdlib.h>
+#include <zlib.h>
#include <png.h>
#include <iostream>
@@ -104,7 +105,7 @@
image.w = width;
image.h = height;
image.bps = bit_depth;
- image.spp = info_ptr->channels;
+ image.spp = png_get_channels(png_ptr, info_ptr);
png_uint_32 res_x, res_y;
res_x = png_get_x_pixels_per_meter(png_ptr, info_ptr);
@@ -120,10 +121,13 @@
// png_set_packswap(png_ptr);
/* Expand paletted colors into true RGB triplets */
+
+ int num_trans;
+
if (color_type == PNG_COLOR_TYPE_PALETTE) {
png_set_palette_to_rgb(png_ptr);
image.bps = 8;
- if (info_ptr->num_trans)
+ if (num_trans)
image.spp = 4;
else
image.spp = 3;