summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/pdftexdir
diff options
context:
space:
mode:
authorPeter Breitenlohner <peb@mppmu.mpg.de>2011-01-31 10:04:05 +0000
committerPeter Breitenlohner <peb@mppmu.mpg.de>2011-01-31 10:04:05 +0000
commit5e5ec7b01f3d69cc335021b3ce0a3e7b5b56a353 (patch)
tree62c35b123ff6ff6cfd75822e7176348fe048c09f /Build/source/texk/web2c/pdftexdir
parent37e0b614acf3dbfeb51949bc24866734121cd0df (diff)
Fix building pdftex with png-1.5
git-svn-id: svn://tug.org/texlive/trunk@21237 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/pdftexdir')
-rw-r--r--Build/source/texk/web2c/pdftexdir/ChangeLog10
-rw-r--r--Build/source/texk/web2c/pdftexdir/writepng.c87
2 files changed, 40 insertions, 57 deletions
diff --git a/Build/source/texk/web2c/pdftexdir/ChangeLog b/Build/source/texk/web2c/pdftexdir/ChangeLog
index 272ee929f6c..191350314c0 100644
--- a/Build/source/texk/web2c/pdftexdir/ChangeLog
+++ b/Build/source/texk/web2c/pdftexdir/ChangeLog
@@ -1,3 +1,13 @@
+2011-01-31 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * writepng.c: Remove png-1.2 cruft.
+
+2011-01-31 Thomas Klausner <tk@giga.or.at>
+
+ * writepng.c: Fix to build with png-1.5 (and avoid `deprecated'
+ warnings with png-1.4). The transformations part is removed on
+ recommendation by John Bowler (a png developer).
+
2011-01-14 Peter Breitenlohner <peb@mppmu.mpg.de>
* pdftex.web: Adapt to ../etexdir/etex.ch:
diff --git a/Build/source/texk/web2c/pdftexdir/writepng.c b/Build/source/texk/web2c/pdftexdir/writepng.c
index 4d87e249e9f..481d4bb6461 100644
--- a/Build/source/texk/web2c/pdftexdir/writepng.c
+++ b/Build/source/texk/web2c/pdftexdir/writepng.c
@@ -21,47 +21,19 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#include "ptexlib.h"
#include "image.h"
-#if PNG_LIBPNG_VER_MINOR > 2
-
/* ToDo:
- * use png_get_PLTE() to access num_palette and palette
- * use xxx to access transformations
+ * Check if multiple use of, e.g., png_bit_depth(img) should be
+ * replaced by
+ * int bitdepth = png_bit_depth(img);
+ * and subsequent use of bitdepth
*/
-
#define png_bit_depth(N) png_get_bit_depth(png_ptr(N), png_info(N))
#define png_color_type(N) png_get_color_type(png_ptr(N), png_info(N))
#define png_height(N) png_get_image_height(png_ptr(N), png_info(N))
#define png_interlace_type(N) png_get_interlace_type(png_ptr(N), png_info(N))
-#define png_io_ptr(N) png_get_io_ptr(png_ptr(N))
-#define png_num_palette(N) png_info(N)->num_palette
-#define png_palette(N) png_info(N)->palette
#define png_rowbytes(N) png_get_rowbytes(png_ptr(N), png_info(N))
-#define png_transformations(N) png_ptr(N)->transformations
-#define png_valid(N,flag) png_get_valid(png_ptr(N), png_info(N), flag)
#define png_width(N) png_get_image_width(png_ptr(N), png_info(N))
-#define png_ptr_bit_depth(N) png_get_bit_depth(png_ptr(N), png_info(N))
-#define png_ptr_color_type(N) png_get_color_type(png_ptr(N), png_info(N))
-
-#else
-
-#define png_bit_depth(N) png_info(N)->bit_depth
-#define png_color_type(N) png_info(N)->color_type
-#define png_height(N) png_info(N)->height
-#define png_interlace_type(N) png_info(N)->interlace_type
-#define png_io_ptr(N) png_ptr(N)->io_ptr
-#define png_num_palette(N) png_info(N)->num_palette
-#define png_palette(N) png_info(N)->palette
-#define png_rowbytes(N) png_info(N)->rowbytes
-#define png_transformations(N) png_ptr(N)->transformations
-#define png_valid(N,flag) png_info(N)->valid & (flag)
-#define png_width(N) png_info(N)->width
-
-#define png_ptr_bit_depth(N) png_ptr(N)->bit_depth
-#define png_ptr_color_type(N) png_ptr(N)->color_type
-
-#endif
-
static int transparent_page_group = -1;
void read_png_info(integer img)
@@ -84,7 +56,7 @@ void read_png_info(integer img)
}
/* alpha channel support */
if (fixedpdfminorversion < 4
- && png_ptr_color_type(img) | PNG_COLOR_MASK_ALPHA)
+ && png_color_type(img) | PNG_COLOR_MASK_ALPHA)
png_set_strip_alpha(png_ptr(img));
/* 16bit depth support */
if (fixedpdfminorversion < 5)
@@ -104,7 +76,7 @@ void read_png_info(integer img)
/* resolution support */
img_width(img) = png_width(img);
img_height(img) = png_height(img);
- if (png_valid(img, PNG_INFO_pHYs)) {
+ if (png_get_valid(png_ptr(img), png_info(img), PNG_INFO_pHYs)) {
img_xres(img) =
round(0.0254 *
png_get_x_pixels_per_meter(png_ptr(img), png_info(img)));
@@ -201,14 +173,18 @@ static void write_png_palette(integer img)
int i, j, k, l;
png_bytep row, r, *rows;
integer palette_objnum = 0;
+ png_colorp palette;
+ int num_palette;
+
+ png_get_PLTE(png_ptr(img), png_info(img), &palette, &num_palette);
+
pdfcreateobj(0, 0);
palette_objnum = objptr;
if (img_colorspace_ref(img) != 0) {
pdf_printf("%i 0 R\n", (int) img_colorspace_ref(img));
} else {
pdf_printf("[/Indexed /DeviceRGB %i %i 0 R]\n",
- (int) (png_num_palette(img) - 1),
- (int) palette_objnum);
+ num_palette -1, (int) palette_objnum);
}
pdfbeginstream();
if (png_interlace_type(img) == PNG_INTERLACE_NONE) {
@@ -230,11 +206,11 @@ static void write_png_palette(integer img)
if (palette_objnum > 0) {
pdfbegindict(palette_objnum, 0);
pdfbeginstream();
- for (i = 0; (unsigned) i < png_num_palette(img); i++) {
+ for (i = 0; (unsigned) i < num_palette; i++) {
pdfroom(3);
- pdfbuf[pdfptr++] = png_palette(img)[i].red;
- pdfbuf[pdfptr++] = png_palette(img)[i].green;
- pdfbuf[pdfptr++] = png_palette(img)[i].blue;
+ pdfbuf[pdfptr++] = palette[i].red;
+ pdfbuf[pdfptr++] = palette[i].green;
+ pdfbuf[pdfptr++] = palette[i].blue;
}
pdfendstream();
}
@@ -461,7 +437,7 @@ static int spng_getint(FILE * fp)
static void copy_png(integer img)
{
- FILE *fp = (FILE *) png_io_ptr(img);
+ FILE *fp = (FILE *) png_get_io_ptr(png_ptr(img));
int i, len, type, streamlength = 0;
boolean endflag = false;
int idat = 0; /* flag to check continuous IDAT chunks sequence */
@@ -553,7 +529,12 @@ void write_png(integer img)
double gamma, checked_gamma;
int i;
integer palette_objnum = 0;
+ png_colorp palette;
+ int num_palette;
last_png_needs_page_group = false;
+
+ png_get_PLTE(png_ptr(img), png_info(img), &palette, &num_palette);
+
if (fixedpdfminorversion < 5)
fixedimagehicolor = 0;
@@ -570,16 +551,12 @@ void write_png(integer img)
checked_gamma = (fixedgamma / 1000.0) * (1000.0 / fixedimagegamma);
}
}
- /* the switching between |png_info| and |png_ptr| queries has been trial and error.
- */
if (fixedpdfminorversion > 1
&& png_interlace_type(img) == PNG_INTERLACE_NONE
- && (png_transformations(img) == PNG_TRANSFORM_IDENTITY
- || png_transformations(img) == 0x2000)
/* gamma */
- && !(png_ptr_color_type(img) == PNG_COLOR_TYPE_GRAY_ALPHA ||
- png_ptr_color_type(img) == PNG_COLOR_TYPE_RGB_ALPHA)
- && (fixedimagehicolor || (png_ptr_bit_depth(img) <= 8))
+ && !(png_color_type(img) == PNG_COLOR_TYPE_GRAY_ALPHA ||
+ png_color_type(img) == PNG_COLOR_TYPE_RGB_ALPHA)
+ && (fixedimagehicolor || (png_bit_depth(img) <= 8))
&& (checked_gamma <= 1.01 && checked_gamma > 0.99)
) {
if (img_colorspace_ref(img) != 0) {
@@ -590,8 +567,7 @@ void write_png(integer img)
pdfcreateobj(0, 0);
palette_objnum = objptr;
pdf_printf("[/Indexed /DeviceRGB %i %i 0 R]\n",
- (int) (png_num_palette(img) - 1),
- (int) palette_objnum);
+ num_palette - 1, (int) palette_objnum);
break;
case PNG_COLOR_TYPE_GRAY:
pdf_puts("/DeviceGray\n");
@@ -605,11 +581,11 @@ void write_png(integer img)
if (palette_objnum > 0) {
pdfbegindict(palette_objnum, 0);
pdfbeginstream();
- for (i = 0; i < png_num_palette(img); i++) {
+ for (i = 0; i < num_palette; i++) {
pdfroom(3);
- pdfbuf[pdfptr++] = png_palette(img)[i].red;
- pdfbuf[pdfptr++] = png_palette(img)[i].green;
- pdfbuf[pdfptr++] = png_palette(img)[i].blue;
+ pdfbuf[pdfptr++] = palette[i].red;
+ pdfbuf[pdfptr++] = palette[i].green;
+ pdfbuf[pdfptr++] = palette[i].blue;
}
pdfendstream();
}
@@ -619,9 +595,6 @@ void write_png(integer img)
if (fixedimageapplygamma &&
(checked_gamma > 1.01 || checked_gamma < 0.99))
tex_printf("gamma delta=%lf ", checked_gamma);
- if (png_transformations(img) != PNG_TRANSFORM_IDENTITY)
- tex_printf("transform=%lu",
- (long) png_transformations(img));
if ((png_color_type(img) != PNG_COLOR_TYPE_GRAY)
&& (png_color_type(img) != PNG_COLOR_TYPE_RGB)
&& (png_color_type(img) != PNG_COLOR_TYPE_PALETTE))