fix libpng issues
This commit is contained in:
parent
5d7860ad94
commit
f089a66693
|
@ -0,0 +1,574 @@
|
|||
diff -up texlive-2007/texk/web2c/pdftexdir/writeimg.c.png15 texlive-2007/texk/web2c/pdftexdir/writeimg.c
|
||||
--- texlive-2007/texk/web2c/pdftexdir/writeimg.c.png15 2012-02-08 15:21:02.318911661 -0500
|
||||
+++ texlive-2007/texk/web2c/pdftexdir/writeimg.c 2012-02-08 15:23:07.870843970 -0500
|
||||
@@ -122,7 +122,11 @@ integer imagecolordepth(integer img)
|
||||
{
|
||||
switch (img_type(img)) {
|
||||
case IMAGE_TYPE_PNG:
|
||||
+#if (PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4) && defined(PNG_EASY_ACCESS_SUPPORTED)
|
||||
+ return png_get_bit_depth(png_ptr(img), png_info(img));
|
||||
+#else
|
||||
return png_info(img)->bit_depth;
|
||||
+#endif
|
||||
case IMAGE_TYPE_JPG:
|
||||
return jpg_ptr(img)->bits_per_component;
|
||||
case IMAGE_TYPE_JBIG2:
|
||||
@@ -364,7 +368,11 @@ void deleteimage(integer img)
|
||||
epdf_delete();
|
||||
break;
|
||||
case IMAGE_TYPE_PNG:
|
||||
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
|
||||
+ xfclose((FILE *) png_get_io_ptr(png_ptr(img)), cur_file_name);
|
||||
+#else
|
||||
xfclose((FILE *) png_ptr(img)->io_ptr, cur_file_name);
|
||||
+#endif
|
||||
png_destroy_read_struct(&(png_ptr(img)), &(png_info(img)), NULL);
|
||||
break;
|
||||
case IMAGE_TYPE_JPG:
|
||||
diff -up texlive-2007/texk/web2c/pdftexdir/writepng.c.png15 texlive-2007/texk/web2c/pdftexdir/writepng.c
|
||||
--- texlive-2007/texk/web2c/pdftexdir/writepng.c.png15 2006-12-26 18:37:34.000000000 -0500
|
||||
+++ texlive-2007/texk/web2c/pdftexdir/writepng.c 2012-02-08 15:17:11.411875292 -0500
|
||||
@@ -33,7 +33,11 @@ void read_png_info(integer img)
|
||||
pdftex_fail("libpng: png_create_read_struct() failed");
|
||||
if ((png_info(img) = png_create_info_struct(png_ptr(img))) == NULL)
|
||||
pdftex_fail("libpng: png_create_info_struct() failed");
|
||||
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
|
||||
+ if (setjmp(png_jmpbuf(png_ptr(img))))
|
||||
+#else
|
||||
if (setjmp(png_ptr(img)->jmpbuf))
|
||||
+#endif
|
||||
pdftex_fail("libpng: internal error");
|
||||
png_init_io(png_ptr(img), png_file);
|
||||
png_read_info(png_ptr(img), png_info(img));
|
||||
@@ -43,12 +47,20 @@ void read_png_info(integer img)
|
||||
}
|
||||
/* alpha channel support */
|
||||
if (fixedpdfminorversion < 4
|
||||
+#if (PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4) && defined(PNG_EASY_ACCESS_SUPPORTED)
|
||||
+ && png_get_color_type(png_ptr(img), png_info(img)) | PNG_COLOR_MASK_ALPHA)
|
||||
+#else
|
||||
&& png_ptr(img)->color_type | PNG_COLOR_MASK_ALPHA)
|
||||
+#endif
|
||||
png_set_strip_alpha(png_ptr(img));
|
||||
/* 16bit depth support */
|
||||
if (fixedpdfminorversion < 5)
|
||||
fixedimagehicolor = 0;
|
||||
+#if (PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4) && defined(PNG_EASY_ACCESS_SUPPORTED)
|
||||
+ if (png_get_bit_depth(png_ptr(img), png_info(img)) == 16 && !fixedimagehicolor)
|
||||
+#else
|
||||
if (png_info(img)->bit_depth == 16 && !fixedimagehicolor)
|
||||
+#endif
|
||||
png_set_strip_16(png_ptr(img));
|
||||
/* gamma support */
|
||||
if (fixedimageapplygamma) {
|
||||
@@ -61,9 +73,18 @@ void read_png_info(integer img)
|
||||
/* reset structure */
|
||||
png_read_update_info(png_ptr(img), png_info(img));
|
||||
/* resolution support */
|
||||
+#if (PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4) && defined(PNG_EASY_ACCESS_SUPPORTED)
|
||||
+ img_width(img) = png_get_image_width(png_ptr(img), png_info(img));
|
||||
+ img_height(img) = png_get_image_height(png_ptr(img), png_info(img));
|
||||
+#else
|
||||
img_width(img) = png_info(img)->width;
|
||||
img_height(img) = png_info(img)->height;
|
||||
+#endif
|
||||
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
|
||||
+ if (png_get_valid(png_ptr(img), png_info(img), PNG_INFO_pHYs)) {
|
||||
+#else
|
||||
if (png_info(img)->valid & PNG_INFO_pHYs) {
|
||||
+#endif
|
||||
img_xres(img) =
|
||||
round(0.0254 *
|
||||
png_get_x_pixels_per_meter(png_ptr(img), png_info(img)));
|
||||
@@ -71,7 +92,11 @@ void read_png_info(integer img)
|
||||
round(0.0254 *
|
||||
png_get_y_pixels_per_meter(png_ptr(img), png_info(img)));
|
||||
}
|
||||
+#if (PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4) && defined(PNG_EASY_ACCESS_SUPPORTED)
|
||||
+ switch (png_get_color_type(png_ptr(img), png_info(img))) {
|
||||
+#else
|
||||
switch (png_info(img)->color_type) {
|
||||
+#endif
|
||||
case PNG_COLOR_TYPE_PALETTE:
|
||||
img_color(img) = IMAGE_COLOR_C | IMAGE_COLOR_I;
|
||||
break;
|
||||
@@ -85,7 +110,11 @@ void read_png_info(integer img)
|
||||
break;
|
||||
default:
|
||||
pdftex_fail("unsupported type of color_type <%i>",
|
||||
+#if (PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4) && defined(PNG_EASY_ACCESS_SUPPORTED)
|
||||
+ png_get_color_type(png_ptr(img), png_info(img)));
|
||||
+#else
|
||||
png_info(img)->color_type);
|
||||
+#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +138,38 @@ void read_png_info(integer img)
|
||||
|
||||
#define write_simple_pixel(r) pdfbuf[pdfptr++] = *r++
|
||||
|
||||
+#if (PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4) && defined(PNG_EASY_ACCESS_SUPPORTED)
|
||||
+#define write_noninterlaced(outmac) \
|
||||
+ for (i = 0; i < (int)png_get_image_height(png_ptr(img), png_info(img)); i++) { \
|
||||
+ png_read_row(png_ptr(img), row, NULL); \
|
||||
+ r = row; \
|
||||
+ k = png_get_rowbytes(png_ptr(img), png_info(img)); \
|
||||
+ while(k > 0) { \
|
||||
+ l = (k > pdfbufsize)? pdfbufsize : k; \
|
||||
+ pdfroom(l); \
|
||||
+ for (j = 0; j < l; j++) { \
|
||||
+ outmac; \
|
||||
+ } \
|
||||
+ k -= l; \
|
||||
+ } \
|
||||
+ }
|
||||
+
|
||||
+#define write_interlaced(outmac) \
|
||||
+ for (i = 0; i < (int)png_get_image_height(png_ptr(img), png_info(img)); i++) { \
|
||||
+ row = rows[i]; \
|
||||
+ k = png_get_rowbytes(png_ptr(img), png_info(img)); \
|
||||
+ while(k > 0) { \
|
||||
+ l = (k > pdfbufsize)? pdfbufsize : k; \
|
||||
+ pdfroom(l); \
|
||||
+ for (j = 0; j < l; j++) { \
|
||||
+ outmac; \
|
||||
+ } \
|
||||
+ k -= l; \
|
||||
+ } \
|
||||
+ xfree(rows[i]); \
|
||||
+ }
|
||||
|
||||
+#else
|
||||
#define write_noninterlaced(outmac) \
|
||||
for (i = 0; i < (int)png_info(img)->height; i++) { \
|
||||
png_read_row(png_ptr(img), row, NULL); \
|
||||
@@ -139,7 +199,7 @@ void read_png_info(integer img)
|
||||
} \
|
||||
xfree(rows[i]); \
|
||||
}
|
||||
-
|
||||
+#endif
|
||||
|
||||
void write_png_palette(integer img)
|
||||
{
|
||||
@@ -148,25 +208,42 @@ void write_png_palette(integer img)
|
||||
integer palette_objnum = 0;
|
||||
pdfcreateobj(0, 0);
|
||||
palette_objnum = objptr;
|
||||
+ int num_palette;
|
||||
+ png_colorp palette;
|
||||
+ png_get_PLTE(png_ptr(img), png_info(img), &palette, &num_palette);
|
||||
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_info(img)->num_palette - 1),
|
||||
+ (int) (num_palette - 1),
|
||||
(int) palette_objnum);
|
||||
}
|
||||
pdfbeginstream();
|
||||
+#if (PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4) && defined(PNG_EASY_ACCESS_SUPPORTED)
|
||||
+ if (png_get_interlace_type(png_ptr(img), png_info(img)) == PNG_INTERLACE_NONE) {
|
||||
+ row = xtalloc(png_get_rowbytes(png_ptr(img), png_info(img)), png_byte);
|
||||
+#else
|
||||
if (png_info(img)->interlace_type == PNG_INTERLACE_NONE) {
|
||||
row = xtalloc(png_info(img)->rowbytes, png_byte);
|
||||
+#endif
|
||||
write_noninterlaced(write_simple_pixel(r));
|
||||
xfree(row);
|
||||
} else {
|
||||
+#if (PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4) && defined(PNG_EASY_ACCESS_SUPPORTED)
|
||||
+ if (png_get_image_height(png_ptr(img), png_info(img)) * png_get_rowbytes(png_ptr(img), png_info(img)) >= 10240000L)
|
||||
+ pdftex_warn
|
||||
+ ("large interlaced PNG might cause out of memory (use non-interlaced PNG to fix this)");
|
||||
+ rows = xtalloc(png_get_image_height(png_ptr(img), png_info(img)), png_bytep);
|
||||
+ for (i = 0; (unsigned) i < png_get_image_height(png_ptr(img), png_info(img)); i++)
|
||||
+ rows[i] = xtalloc(png_get_rowbytes(png_ptr(img), png_info(img)), png_byte);
|
||||
+#else
|
||||
if (png_info(img)->height * png_info(img)->rowbytes >= 10240000L)
|
||||
pdftex_warn
|
||||
("large interlaced PNG might cause out of memory (use non-interlaced PNG to fix this)");
|
||||
rows = xtalloc(png_info(img)->height, png_bytep);
|
||||
for (i = 0; (unsigned) i < png_info(img)->height; i++)
|
||||
rows[i] = xtalloc(png_info(img)->rowbytes, png_byte);
|
||||
+#endif
|
||||
png_read_image(png_ptr(img), rows);
|
||||
write_interlaced(write_simple_pixel(row));
|
||||
xfree(rows);
|
||||
@@ -175,11 +252,12 @@ void write_png_palette(integer img)
|
||||
if (palette_objnum > 0) {
|
||||
pdfbegindict(palette_objnum, 0);
|
||||
pdfbeginstream();
|
||||
- for (i = 0; (unsigned) i < png_info(img)->num_palette; i++) {
|
||||
+ png_get_PLTE(png_ptr(img), png_info(img), &palette, &num_palette);
|
||||
+ for (i = 0; (unsigned) i < num_palette; i++) {
|
||||
pdfroom(3);
|
||||
- pdfbuf[pdfptr++] = png_info(img)->palette[i].red;
|
||||
- pdfbuf[pdfptr++] = png_info(img)->palette[i].green;
|
||||
- pdfbuf[pdfptr++] = png_info(img)->palette[i].blue;
|
||||
+ pdfbuf[pdfptr++] = palette[i].red;
|
||||
+ pdfbuf[pdfptr++] = palette[i].green;
|
||||
+ pdfbuf[pdfptr++] = palette[i].blue;
|
||||
}
|
||||
pdfendstream();
|
||||
}
|
||||
@@ -195,17 +273,31 @@ void write_png_gray(integer img)
|
||||
pdf_puts("/DeviceGray\n");
|
||||
}
|
||||
pdfbeginstream();
|
||||
+#if (PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4) && defined(PNG_EASY_ACCESS_SUPPORTED)
|
||||
+ if (png_get_interlace_type(png_ptr(img), png_info(img)) == PNG_INTERLACE_NONE) {
|
||||
+ row = xtalloc(png_get_rowbytes(png_ptr(img), png_info(img)), png_byte);
|
||||
+#else
|
||||
if (png_info(img)->interlace_type == PNG_INTERLACE_NONE) {
|
||||
row = xtalloc(png_info(img)->rowbytes, png_byte);
|
||||
+#endif
|
||||
write_noninterlaced(write_simple_pixel(r));
|
||||
xfree(row);
|
||||
} else {
|
||||
+#if (PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4) && defined(PNG_EASY_ACCESS_SUPPORTED)
|
||||
+ if (png_get_image_height(png_ptr(img), png_info(img)) * png_get_rowbytes(png_ptr(img), png_info(img)) >= 10240000L)
|
||||
+ pdftex_warn
|
||||
+ ("large interlaced PNG might cause out of memory (use non-interlaced PNG to fix this)");
|
||||
+ rows = xtalloc(png_get_image_height(png_ptr(img), png_info(img)), png_bytep);
|
||||
+ for (i = 0; (unsigned) i < png_get_image_height(png_ptr(img), png_info(img)); i++)
|
||||
+ rows[i] = xtalloc(png_get_rowbytes(png_ptr(img), png_info(img)), png_byte);
|
||||
+#else
|
||||
if (png_info(img)->height * png_info(img)->rowbytes >= 10240000L)
|
||||
pdftex_warn
|
||||
("large interlaced PNG might cause out of memory (use non-interlaced PNG to fix this)");
|
||||
rows = xtalloc(png_info(img)->height, png_bytep);
|
||||
for (i = 0; (unsigned) i < png_info(img)->height; i++)
|
||||
rows[i] = xtalloc(png_info(img)->rowbytes, png_byte);
|
||||
+#endif
|
||||
png_read_image(png_ptr(img), rows);
|
||||
write_interlaced(write_simple_pixel(row));
|
||||
xfree(rows);
|
||||
@@ -232,26 +324,49 @@ void write_png_gray_alpha(integer img)
|
||||
pdfcreateobj(0, 0);
|
||||
smask_objnum = objptr;
|
||||
pdf_printf("/SMask %i 0 R\n", (int) smask_objnum);
|
||||
+#if (PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4) && defined(PNG_EASY_ACCESS_SUPPORTED)
|
||||
+ smask_size = (png_get_rowbytes(png_ptr(img), png_info(img)) / 2) * png_get_image_height(png_ptr(img), png_info(img));
|
||||
+#else
|
||||
smask_size = (png_info(img)->rowbytes / 2) * png_info(img)->height;
|
||||
+#endif
|
||||
smask = xtalloc(smask_size, png_byte);
|
||||
pdfbeginstream();
|
||||
+#if (PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4) && defined(PNG_EASY_ACCESS_SUPPORTED)
|
||||
+ if (png_get_interlace_type(png_ptr(img), png_info(img)) == PNG_INTERLACE_NONE) {
|
||||
+ row = xtalloc(png_get_rowbytes(png_ptr(img), png_info(img)), png_byte);
|
||||
+ if ((png_get_bit_depth(png_ptr(img), png_info(img)) == 16) && fixedimagehicolor) {
|
||||
+#else
|
||||
if (png_info(img)->interlace_type == PNG_INTERLACE_NONE) {
|
||||
row = xtalloc(png_info(img)->rowbytes, png_byte);
|
||||
if ((png_info(img)->bit_depth == 16) && fixedimagehicolor) {
|
||||
+#endif
|
||||
write_noninterlaced(write_gray_pixel_16(r));
|
||||
} else {
|
||||
write_noninterlaced(write_gray_pixel_8(r));
|
||||
}
|
||||
xfree(row);
|
||||
} else {
|
||||
+#if (PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4) && defined(PNG_EASY_ACCESS_SUPPORTED)
|
||||
+ if (png_get_image_height(png_ptr(img), png_info(img)) * png_get_rowbytes(png_ptr(img), png_info(img)) >= 10240000L)
|
||||
+ pdftex_warn
|
||||
+ ("large interlaced PNG might cause out of memory (use non-interlaced PNG to fix this)");
|
||||
+ rows = xtalloc(png_get_image_height(png_ptr(img), png_info(img)), png_bytep);
|
||||
+ for (i = 0; (unsigned) i < png_get_image_height(png_ptr(img), png_info(img)); i++)
|
||||
+ rows[i] = xtalloc(png_get_rowbytes(png_ptr(img), png_info(img)), png_byte);
|
||||
+#else
|
||||
if (png_info(img)->height * png_info(img)->rowbytes >= 10240000L)
|
||||
pdftex_warn
|
||||
("large interlaced PNG might cause out of memory (use non-interlaced PNG to fix this)");
|
||||
rows = xtalloc(png_info(img)->height, png_bytep);
|
||||
for (i = 0; (unsigned) i < png_info(img)->height; i++)
|
||||
rows[i] = xtalloc(png_info(img)->rowbytes, png_byte);
|
||||
+#endif
|
||||
png_read_image(png_ptr(img), rows);
|
||||
+#if (PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4) && defined(PNG_EASY_ACCESS_SUPPORTED)
|
||||
+ if ((png_get_bit_depth(png_ptr(img), png_info(img)) == 16) && fixedimagehicolor) {
|
||||
+#else
|
||||
if ((png_info(img)->bit_depth == 16) && fixedimagehicolor) {
|
||||
+#endif
|
||||
write_interlaced(write_gray_pixel_16(row));
|
||||
} else {
|
||||
write_interlaced(write_gray_pixel_8(row));
|
||||
@@ -262,12 +377,21 @@ void write_png_gray_alpha(integer img)
|
||||
pdfflush();
|
||||
/* now write the Smask object */
|
||||
if (smask_objnum > 0) {
|
||||
+#if (PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4) && defined(PNG_EASY_ACCESS_SUPPORTED)
|
||||
+ bitdepth = (int) png_get_bit_depth(png_ptr(img), png_info(img));
|
||||
+#else
|
||||
bitdepth = (int) png_info(img)->bit_depth;
|
||||
+#endif
|
||||
pdfbegindict(smask_objnum, 0);
|
||||
pdf_puts("/Type /XObject\n/Subtype /Image\n");
|
||||
pdf_printf("/Width %i\n/Height %i\n/BitsPerComponent %i\n",
|
||||
+#if (PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4) && defined(PNG_EASY_ACCESS_SUPPORTED)
|
||||
+ (int) png_get_image_width(png_ptr(img), png_info(img)),
|
||||
+ (int) png_get_image_height(png_ptr(img), png_info(img)),
|
||||
+#else
|
||||
(int) png_info(img)->width,
|
||||
(int) png_info(img)->height,
|
||||
+#endif
|
||||
(bitdepth == 16 ? 8 : bitdepth));
|
||||
pdf_puts("/ColorSpace /DeviceGray\n");
|
||||
pdfbeginstream();
|
||||
@@ -293,17 +417,31 @@ void write_png_rgb(integer img)
|
||||
pdf_puts("/DeviceRGB\n");
|
||||
}
|
||||
pdfbeginstream();
|
||||
+#if (PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4) && defined(PNG_EASY_ACCESS_SUPPORTED)
|
||||
+ if (png_get_interlace_type(png_ptr(img), png_info(img)) == PNG_INTERLACE_NONE) {
|
||||
+ row = xtalloc(png_get_rowbytes(png_ptr(img), png_info(img)), png_byte);
|
||||
+#else
|
||||
if (png_info(img)->interlace_type == PNG_INTERLACE_NONE) {
|
||||
row = xtalloc(png_info(img)->rowbytes, png_byte);
|
||||
+#endif
|
||||
write_noninterlaced(write_simple_pixel(r));
|
||||
xfree(row);
|
||||
} else {
|
||||
+#if (PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4) && defined(PNG_EASY_ACCESS_SUPPORTED)
|
||||
+ if (png_get_image_height(png_ptr(img), png_info(img)) * png_get_rowbytes(png_ptr(img), png_info(img)) >= 10240000L)
|
||||
+ pdftex_warn
|
||||
+ ("large interlaced PNG might cause out of memory (use non-interlaced PNG to fix this)");
|
||||
+ rows = xtalloc(png_get_image_height(png_ptr(img), png_info(img)), png_bytep);
|
||||
+ for (i = 0; (unsigned) i < png_get_image_height(png_ptr(img), png_info(img)); i++)
|
||||
+ rows[i] = xtalloc(png_get_rowbytes(png_ptr(img), png_info(img)), png_byte);
|
||||
+#else
|
||||
if (png_info(img)->height * png_info(img)->rowbytes >= 10240000L)
|
||||
pdftex_warn
|
||||
("large interlaced PNG might cause out of memory (use non-interlaced PNG to fix this)");
|
||||
rows = xtalloc(png_info(img)->height, png_bytep);
|
||||
for (i = 0; (unsigned) i < png_info(img)->height; i++)
|
||||
rows[i] = xtalloc(png_info(img)->rowbytes, png_byte);
|
||||
+#endif
|
||||
png_read_image(png_ptr(img), rows);
|
||||
write_interlaced(write_simple_pixel(row));
|
||||
xfree(rows);
|
||||
@@ -328,26 +466,49 @@ void write_png_rgb_alpha(integer img)
|
||||
pdfcreateobj(0, 0);
|
||||
smask_objnum = objptr;
|
||||
pdf_printf("/SMask %i 0 R\n", (int) smask_objnum);
|
||||
+#if (PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4) && defined(PNG_EASY_ACCESS_SUPPORTED)
|
||||
+ smask_size = (png_get_rowbytes(png_ptr(img), png_info(img)) / 2) * png_get_image_height(png_ptr(img), png_info(img));
|
||||
+#else
|
||||
smask_size = (png_info(img)->rowbytes / 2) * png_info(img)->height;
|
||||
+#endif
|
||||
smask = xtalloc(smask_size, png_byte);
|
||||
pdfbeginstream();
|
||||
+#if (PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4) && defined(PNG_EASY_ACCESS_SUPPORTED)
|
||||
+ if (png_get_interlace_type(png_ptr(img), png_info(img)) == PNG_INTERLACE_NONE) {
|
||||
+ row = xtalloc(png_get_rowbytes(png_ptr(img), png_info(img)), png_byte);
|
||||
+ if ((png_get_bit_depth(png_ptr(img), png_info(img)) == 16) && fixedimagehicolor) {
|
||||
+#else
|
||||
if (png_info(img)->interlace_type == PNG_INTERLACE_NONE) {
|
||||
row = xtalloc(png_info(img)->rowbytes, png_byte);
|
||||
if ((png_info(img)->bit_depth == 16) && fixedimagehicolor) {
|
||||
+#endif
|
||||
write_noninterlaced(write_rgb_pixel_16(r));
|
||||
} else {
|
||||
write_noninterlaced(write_rgb_pixel_8(r));
|
||||
}
|
||||
xfree(row);
|
||||
} else {
|
||||
+#if (PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4) && defined(PNG_EASY_ACCESS_SUPPORTED)
|
||||
+ if (png_get_image_height(png_ptr(img), png_info(img)) * png_get_rowbytes(png_ptr(img), png_info(img)) >= 10240000L)
|
||||
+ pdftex_warn
|
||||
+ ("large interlaced PNG might cause out of memory (use non-interlaced PNG to fix this)");
|
||||
+ rows = xtalloc(png_get_image_height(png_ptr(img), png_info(img)), png_bytep);
|
||||
+ for (i = 0; (unsigned) i < png_get_image_height(png_ptr(img), png_info(img)); i++)
|
||||
+ rows[i] = xtalloc(png_get_rowbytes(png_ptr(img), png_info(img)), png_byte);
|
||||
+#else
|
||||
if (png_info(img)->height * png_info(img)->rowbytes >= 10240000L)
|
||||
pdftex_warn
|
||||
("large interlaced PNG might cause out of memory (use non-interlaced PNG to fix this)");
|
||||
rows = xtalloc(png_info(img)->height, png_bytep);
|
||||
for (i = 0; (unsigned) i < png_info(img)->height; i++)
|
||||
rows[i] = xtalloc(png_info(img)->rowbytes, png_byte);
|
||||
+#endif
|
||||
png_read_image(png_ptr(img), rows);
|
||||
+#if (PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4) && defined(PNG_EASY_ACCESS_SUPPORTED)
|
||||
+ if ((png_get_bit_depth(png_ptr(img), png_info(img)) == 16) && fixedimagehicolor) {
|
||||
+#else
|
||||
if ((png_info(img)->bit_depth == 16) && fixedimagehicolor) {
|
||||
+#endif
|
||||
write_interlaced(write_rgb_pixel_16(row));
|
||||
} else {
|
||||
write_interlaced(write_rgb_pixel_8(row));
|
||||
@@ -358,12 +519,21 @@ void write_png_rgb_alpha(integer img)
|
||||
pdfflush();
|
||||
/* now write the Smask object */
|
||||
if (smask_objnum > 0) {
|
||||
+#if (PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4) && defined(PNG_EASY_ACCESS_SUPPORTED)
|
||||
+ bitdepth = (int) png_get_bit_depth(png_ptr(img), png_info(img));
|
||||
+#else
|
||||
bitdepth = (int) png_info(img)->bit_depth;
|
||||
+#endif
|
||||
pdfbegindict(smask_objnum, 0);
|
||||
pdf_puts("/Type /XObject\n/Subtype /Image\n");
|
||||
pdf_printf("/Width %i\n/Height %i\n/BitsPerComponent %i\n",
|
||||
+#if (PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4) && defined(PNG_EASY_ACCESS_SUPPORTED)
|
||||
+ (int) png_get_image_width(png_ptr(img), png_info(img)),
|
||||
+ (int) png_get_image_height(png_ptr(img), png_info(img)),
|
||||
+#else
|
||||
(int) png_info(img)->width,
|
||||
(int) png_info(img)->height,
|
||||
+#endif
|
||||
(bitdepth == 16 ? 8 : bitdepth));
|
||||
pdf_puts("/ColorSpace /DeviceGray\n");
|
||||
pdfbeginstream();
|
||||
@@ -406,7 +576,11 @@ static int spng_getint(FILE * fp)
|
||||
|
||||
void copy_png(integer img)
|
||||
{
|
||||
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
|
||||
+ FILE *fp = (FILE *) png_get_io_ptr(png_ptr(img));
|
||||
+#else
|
||||
FILE *fp = (FILE *) png_ptr(img)->io_ptr;
|
||||
+#endif
|
||||
int i, len, type, streamlength = 0;
|
||||
boolean endflag = false;
|
||||
int idat = 0; /* flag to check continuous IDAT chunks sequence */
|
||||
@@ -430,9 +604,15 @@ void copy_png(integer img)
|
||||
pdf_printf("/Length %d\n", streamlength);
|
||||
pdf_printf("/Filter /FlateDecode\n");
|
||||
pdf_printf("/DecodeParms << ");
|
||||
+#if (PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4) && defined(PNG_EASY_ACCESS_SUPPORTED)
|
||||
+ pdf_printf("/Colors %d ", png_get_color_type(png_ptr(img), png_info(img)) == 2 ? 3 : 1);
|
||||
+ pdf_printf("/Columns %d ", (int) png_get_image_width(png_ptr(img), png_info(img)));
|
||||
+ pdf_printf("/BitsPerComponent %i ", (int) png_get_bit_depth(png_ptr(img), png_info(img)));
|
||||
+#else
|
||||
pdf_printf("/Colors %d ", png_info(img)->color_type == 2 ? 3 : 1);
|
||||
pdf_printf("/Columns %d ", (int) png_info(img)->width);
|
||||
pdf_printf("/BitsPerComponent %i ", (int) png_info(img)->bit_depth);
|
||||
+#endif
|
||||
pdf_printf("/Predictor %d ", 10); /* actual predictor defined on line basis */
|
||||
pdf_printf(">>\n>>\nstream\n");
|
||||
/* 2nd pass to copy data */
|
||||
@@ -481,8 +661,13 @@ void write_png(integer img)
|
||||
|
||||
pdf_puts("/Type /XObject\n/Subtype /Image\n");
|
||||
pdf_printf("/Width %i\n/Height %i\n/BitsPerComponent %i\n",
|
||||
+#if (PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4) && defined(PNG_EASY_ACCESS_SUPPORTED)
|
||||
+ (int) png_get_image_width(png_ptr(img), png_info(img)),
|
||||
+ (int) png_get_image_height(png_ptr(img), png_info(img)), (int) png_get_bit_depth(png_ptr(img), png_info(img)));
|
||||
+#else
|
||||
(int) png_info(img)->width,
|
||||
(int) png_info(img)->height, (int) png_info(img)->bit_depth);
|
||||
+#endif
|
||||
pdf_puts("/ColorSpace ");
|
||||
checked_gamma = 1.0;
|
||||
if (fixedimageapplygamma) {
|
||||
@@ -492,23 +677,37 @@ void write_png(integer img)
|
||||
checked_gamma = (fixedgamma / 1000.0) * (1000.0 / fixedimagegamma);
|
||||
}
|
||||
}
|
||||
+ int num_palette;
|
||||
+ png_colorp palette;
|
||||
+ png_get_PLTE(png_ptr(img), png_info(img), &palette, &num_palette);
|
||||
/* the switching between |png_info| and |png_ptr| queries has been trial and error.
|
||||
*/
|
||||
+#if (PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4) && defined(PNG_EASY_ACCESS_SUPPORTED)
|
||||
+ if (fixedpdfminorversion > 1 && png_get_interlace_type(png_ptr(img), png_info(img)) == PNG_INTERLACE_NONE /* gamma */
|
||||
+ &&!(png_get_color_type(png_ptr(img), png_info(img)) == PNG_COLOR_TYPE_GRAY_ALPHA ||
|
||||
+ png_get_color_type(png_ptr(img), png_info(img)) == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
+ && (fixedimagehicolor || (png_get_bit_depth(png_ptr(img), png_info(img)) <= 8))
|
||||
+#else
|
||||
if (fixedpdfminorversion > 1 && png_info(img)->interlace_type == PNG_INTERLACE_NONE && (png_ptr(img)->transformations == 0 || png_ptr(img)->transformations == 0x2000) /* gamma */
|
||||
&&!(png_ptr(img)->color_type == PNG_COLOR_TYPE_GRAY_ALPHA ||
|
||||
png_ptr(img)->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
&& (fixedimagehicolor || (png_ptr(img)->bit_depth <= 8))
|
||||
+#endif
|
||||
&& (checked_gamma <= 1.01 && checked_gamma > 0.99)
|
||||
) {
|
||||
if (img_colorspace_ref(img) != 0) {
|
||||
pdf_printf("%i 0 R\n", (int) img_colorspace_ref(img));
|
||||
} else {
|
||||
+#if (PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4) && defined(PNG_EASY_ACCESS_SUPPORTED)
|
||||
+ switch (png_get_color_type(png_ptr(img), png_info(img))) {
|
||||
+#else
|
||||
switch (png_info(img)->color_type) {
|
||||
+#endif
|
||||
case PNG_COLOR_TYPE_PALETTE:
|
||||
pdfcreateobj(0, 0);
|
||||
palette_objnum = objptr;
|
||||
pdf_printf("[/Indexed /DeviceRGB %i %i 0 R]\n",
|
||||
- (int) (png_info(img)->num_palette - 1),
|
||||
+ (int) (num_palette - 1),
|
||||
(int) palette_objnum);
|
||||
break;
|
||||
case PNG_COLOR_TYPE_GRAY:
|
||||
@@ -523,11 +722,12 @@ void write_png(integer img)
|
||||
if (palette_objnum > 0) {
|
||||
pdfbegindict(palette_objnum, 0);
|
||||
pdfbeginstream();
|
||||
- for (i = 0; i < png_info(img)->num_palette; i++) {
|
||||
+ png_get_PLTE(png_ptr(img), png_info(img), &palette, &num_palette);
|
||||
+ for (i = 0; i < num_palette; i++) {
|
||||
pdfroom(3);
|
||||
- pdfbuf[pdfptr++] = png_info(img)->palette[i].red;
|
||||
- pdfbuf[pdfptr++] = png_info(img)->palette[i].green;
|
||||
- pdfbuf[pdfptr++] = png_info(img)->palette[i].blue;
|
||||
+ pdfbuf[pdfptr++] = palette[i].red;
|
||||
+ pdfbuf[pdfptr++] = palette[i].green;
|
||||
+ pdfbuf[pdfptr++] = palette[i].blue;
|
||||
}
|
||||
pdfendstream();
|
||||
}
|
||||
@@ -537,23 +737,37 @@ void write_png(integer img)
|
||||
if (fixedimageapplygamma &&
|
||||
(checked_gamma > 1.01 || checked_gamma < 0.99))
|
||||
tex_printf("gamma delta=%lf ", checked_gamma);
|
||||
- if (png_ptr(img)->transformations != PNG_TRANSFORM_IDENTITY)
|
||||
- tex_printf("transform=%lu",
|
||||
- (long) png_ptr(img)->transformations);
|
||||
+#if (PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4) && defined(PNG_EASY_ACCESS_SUPPORTED)
|
||||
+ if ((png_get_color_type(png_ptr(img), png_info(img)) != PNG_COLOR_TYPE_GRAY)
|
||||
+ && (png_get_color_type(png_ptr(img), png_info(img)) != PNG_COLOR_TYPE_RGB)
|
||||
+ && (png_get_color_type(png_ptr(img), png_info(img)) != PNG_COLOR_TYPE_PALETTE))
|
||||
+#else
|
||||
if ((png_info(img)->color_type != PNG_COLOR_TYPE_GRAY)
|
||||
&& (png_info(img)->color_type != PNG_COLOR_TYPE_RGB)
|
||||
&& (png_info(img)->color_type != PNG_COLOR_TYPE_PALETTE))
|
||||
+#endif
|
||||
tex_printf("colortype ");
|
||||
if (fixedpdfminorversion <= 1)
|
||||
tex_printf("version=%d ", (int) fixedpdfminorversion);
|
||||
+#if (PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4) && defined(PNG_EASY_ACCESS_SUPPORTED)
|
||||
+ if (png_get_interlace_type(png_ptr(img), png_info(img)) != PNG_INTERLACE_NONE)
|
||||
+ tex_printf("interlaced ");
|
||||
+ if (png_get_bit_depth(png_ptr(img), png_info(img)) > 8)
|
||||
+ tex_printf("bitdepth=%d ", png_get_bit_depth(png_ptr(img), png_info(img)));
|
||||
+#else
|
||||
if (png_info(img)->interlace_type != PNG_INTERLACE_NONE)
|
||||
tex_printf("interlaced ");
|
||||
if (png_info(img)->bit_depth > 8)
|
||||
tex_printf("bitdepth=%d ", png_info(img)->bit_depth);
|
||||
+#endif
|
||||
if (png_get_valid(png_ptr(img), png_info(img), PNG_INFO_tRNS))
|
||||
tex_printf("simple transparancy ");
|
||||
}
|
||||
+#if (PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4) && defined(PNG_EASY_ACCESS_SUPPORTED)
|
||||
+ switch (png_get_color_type(png_ptr(img), png_info(img))) {
|
||||
+#else
|
||||
switch (png_info(img)->color_type) {
|
||||
+#endif
|
||||
case PNG_COLOR_TYPE_PALETTE:
|
||||
write_png_palette(img);
|
||||
break;
|
||||
@@ -577,7 +791,11 @@ void write_png(integer img)
|
||||
break;
|
||||
default:
|
||||
pdftex_fail("unsupported type of color_type <%i>",
|
||||
+#if (PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4) && defined(PNG_EASY_ACCESS_SUPPORTED)
|
||||
+ png_get_color_type(png_ptr(img), png_info(img)));
|
||||
+#else
|
||||
png_info(img)->color_type);
|
||||
+#endif
|
||||
}
|
||||
}
|
||||
pdfflush();
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
Name: texlive
|
||||
Version: %{texlive_ver}
|
||||
Release: 69%{?dist}
|
||||
Release: 70%{?dist}
|
||||
Summary: Binaries for the TeX formatting system
|
||||
|
||||
Group: Applications/Publishing
|
||||
|
@ -132,6 +132,8 @@ Patch1005: texlive-2007-pdvips.patch
|
|||
Patch1006: texlive-2007-ptex-3.1.10.patch
|
||||
Patch1007: texlive-2007-fmtutil-ptex.patch
|
||||
|
||||
Patch1100: texlive-2007-png15.patch
|
||||
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
|
||||
BuildRequires: flex bison ed xdg-utils
|
||||
|
@ -141,6 +143,7 @@ BuildRequires: libSM-devel libICE-devel
|
|||
# for non-modular xorg - use xorg-devel instead of above
|
||||
BuildRequires: Xaw3d-devel
|
||||
BuildRequires: poppler-devel >= 0.6.2-2
|
||||
BuildRequires: poppler-cpp-devel
|
||||
BuildRequires: teckit-devel
|
||||
Requires: texlive-texmf = %{version}
|
||||
Requires: texlive-texmf-fonts = %{version}
|
||||
|
@ -451,6 +454,8 @@ chmod -x texk/dvipdfm/encodings.c
|
|||
|
||||
%patch1007 -p1 -b .ptex
|
||||
|
||||
%patch1100 -p1 -b .png15
|
||||
|
||||
%if %{disable_lcdf_typetools}
|
||||
pushd utils
|
||||
rm -rf lcdf-typetools
|
||||
|
|
Loading…
Reference in New Issue