summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/luatexdir/image/writepng.w
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/image/writepng.w')
-rw-r--r--Build/source/texk/web2c/luatexdir/image/writepng.w319
1 files changed, 163 insertions, 156 deletions
diff --git a/Build/source/texk/web2c/luatexdir/image/writepng.w b/Build/source/texk/web2c/luatexdir/image/writepng.w
index 40f8e0e2635..412000c427f 100644
--- a/Build/source/texk/web2c/luatexdir/image/writepng.w
+++ b/Build/source/texk/web2c/luatexdir/image/writepng.w
@@ -20,7 +20,6 @@
@ @c
-
#include "ptexlib.h"
#include <assert.h>
#include "image/image.h"
@@ -31,45 +30,55 @@ static int transparent_page_group = -1;
static void close_and_cleanup_png(image_dict * idict)
{
- assert(idict != NULL);
- assert(img_file(idict) != NULL);
- assert(img_filepath(idict) != NULL);
- xfclose(img_file(idict), img_filepath(idict));
- img_file(idict) = NULL;
- assert(img_png_ptr(idict) != NULL);
- png_destroy_read_struct(&(img_png_png_ptr(idict)),
- &(img_png_info_ptr(idict)), NULL);
- xfree(img_png_ptr(idict));
+ /* if one of then is not NULL we already cleaned up */
+ if (img_file(idict) != NULL) {
+ xfclose(img_file(idict), img_filepath(idict));
+ img_file(idict) = NULL;
+ }
+ if (img_png_ptr(idict) != NULL) {
+ png_destroy_read_struct(&(img_png_png_ptr(idict)), &(img_png_info_ptr(idict)), NULL);
+ xfree(img_png_ptr(idict));
+ }
+}
+
+@ @c
+void flush_png_info(image_dict * idict)
+{
+ close_and_cleanup_png(idict);
}
@ @c
static void warn(png_structp png_ptr, png_const_charp msg)
{
- (void)png_ptr; (void)msg; /* Make compiler happy */
+ (void)png_ptr; (void)msg; /* Make compiler happy */
}
-void read_png_info(image_dict * idict, img_readtype_e readtype)
+void read_png_info(image_dict * idict)
{
png_structp png_p;
png_infop info_p;
- assert(idict != NULL);
- assert(img_type(idict) == IMG_TYPE_PNG);
+ if (img_type(idict) != IMG_TYPE_PNG) {
+ normal_error("readpng","conflicting image dictionary");
+ }
+ if (img_file(idict) != NULL) {
+ normal_error("readpng","image data already read");
+ }
img_totalpages(idict) = 1;
img_pagenum(idict) = 1;
img_xres(idict) = img_yres(idict) = 0;
- assert(img_file(idict) == NULL);
img_file(idict) = xfopen(img_filepath(idict), FOPEN_RBIN_MODE);
- assert(img_png_ptr(idict) == NULL);
img_png_ptr(idict) = xtalloc(1, png_img_struct);
- if ((png_p = png_create_read_struct(PNG_LIBPNG_VER_STRING,
- NULL, NULL, warn)) == NULL)
- luatex_fail("libpng: png_create_read_struct() failed");
+ if ((png_p = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, warn)) == NULL) {
+ normal_error("readpng","png_create_read_struct() failed");
+ }
img_png_png_ptr(idict) = png_p;
- if ((info_p = png_create_info_struct(png_p)) == NULL)
- luatex_fail("libpng: png_create_info_struct() failed");
+ if ((info_p = png_create_info_struct(png_p)) == NULL) {
+ normal_error("readpng","png_create_info_struct() failed");
+ }
img_png_info_ptr(idict) = info_p;
- if (setjmp(png_jmpbuf(png_p)))
- luatex_fail("libpng: internal error");
+ if (setjmp(png_jmpbuf(png_p))) {
+ normal_error("readpng","internal error");
+ }
#if PNG_LIBPNG_VER >= 10603
/* ignore possibly incorrect CMF bytes */
png_set_option(png_p, PNG_MAXIMUM_INFLATE_WINDOW, PNG_OPTION_ON);
@@ -80,10 +89,8 @@ void read_png_info(image_dict * idict, img_readtype_e readtype)
img_xsize(idict) = (int) png_get_image_width(png_p, info_p);
img_ysize(idict) = (int) png_get_image_height(png_p, info_p);
if (png_get_valid(png_p, info_p, PNG_INFO_pHYs)) {
- img_xres(idict) =
- round(0.0254 * (double) png_get_x_pixels_per_meter(png_p, info_p));
- img_yres(idict) =
- round(0.0254 * (double) png_get_y_pixels_per_meter(png_p, info_p));
+ img_xres(idict) = round(0.0254 * (double) png_get_x_pixels_per_meter(png_p, info_p));
+ img_yres(idict) = round(0.0254 * (double) png_get_y_pixels_per_meter(png_p, info_p));
}
switch (png_get_color_type(png_p, info_p)) {
case PNG_COLOR_TYPE_PALETTE:
@@ -98,12 +105,15 @@ void read_png_info(image_dict * idict, img_readtype_e readtype)
img_procset(idict) |= PROCSET_IMAGE_C;
break;
default:
- luatex_fail("unsupported type of color_type <%i>",
- (int) png_get_color_type(png_p, info_p));
+ formatted_error("readpng","unsupported type of color_type '%i'",(int) png_get_color_type(png_p, info_p));
}
img_colordepth(idict) = png_get_bit_depth(png_p, info_p);
- if (readtype == IMG_CLOSEINBETWEEN)
+ /*
+ So we can optionally keep open a file in img.
+ */
+ if (! img_keepopen(idict)) {
close_and_cleanup_png(idict);
+ }
}
@ @c
@@ -164,8 +174,7 @@ void read_png_info(image_dict * idict, img_readtype_e readtype)
}
@ @c
-static void write_palette_streamobj(PDF pdf, int palette_objnum,
- png_colorp palette, int num_palette)
+static void write_palette_streamobj(PDF pdf, int palette_objnum, png_colorp palette, int num_palette)
{
int i;
if (palette_objnum == 0)
@@ -187,8 +196,7 @@ static void write_palette_streamobj(PDF pdf, int palette_objnum,
}
@ @c
-static void write_smask_streamobj(PDF pdf, image_dict * idict, int smask_objnum,
- png_bytep smask, int smask_size)
+static void write_smask_streamobj(PDF pdf, image_dict * idict, int smask_objnum, png_bytep smask, int smask_size)
{
int i;
png_structp png_p = img_png_png_ptr(idict);
@@ -235,13 +243,13 @@ static void write_png_gray(PDF pdf, image_dict * idict)
write_noninterlaced(write_simple_pixel(r));
xfree(row);
} else {
- if (png_get_image_height(png_p, info_p) *
- png_get_rowbytes(png_p, info_p) >= 10240000L)
- luatex_warn
- ("large interlaced PNG might cause out of memory (use non-interlaced PNG to fix this)");
+ if (png_get_image_height(png_p, info_p) * png_get_rowbytes(png_p, info_p) >= 10240000L) {
+ formatted_warning("pngwrite","large interlaced bitmap might cause out of memory");
+ }
rows = xtalloc(png_get_image_height(png_p, info_p), png_bytep);
- for (i = 0; i < (int) png_get_image_height(png_p, info_p); i++)
+ for (i = 0; i < (int) png_get_image_height(png_p, info_p); i++) {
rows[i] = xtalloc(png_get_rowbytes(png_p, info_p), png_byte);
+ }
png_read_image(png_p, rows);
write_interlaced(write_simple_pixel(row));
xfree(rows);
@@ -264,33 +272,29 @@ static void write_png_gray_alpha(PDF pdf, image_dict * idict)
int smask_size = 0;
smask_objnum = pdf_create_obj(pdf, obj_type_others, 0);
pdf_dict_add_ref(pdf, "SMask", (int) smask_objnum);
- smask_size =
- (int) ((png_get_rowbytes(png_p, info_p) / 2) *
- png_get_image_height(png_p, info_p));
+ smask_size = (int) ((png_get_rowbytes(png_p, info_p) / 2) * png_get_image_height(png_p, info_p));
smask = xtalloc((unsigned) smask_size, png_byte);
pdf_dict_add_streaminfo(pdf);
pdf_end_dict(pdf);
pdf_begin_stream(pdf);
if (png_get_interlace_type(png_p, info_p) == PNG_INTERLACE_NONE) {
row = xtalloc(png_get_rowbytes(png_p, info_p), png_byte);
- if ((png_get_bit_depth(png_p, info_p) == 16)
- && (pdf->image_hicolor != 0)) {
+ if ((png_get_bit_depth(png_p, info_p) == 16) && (pdf->image_hicolor != 0)) {
write_noninterlaced(write_gray_pixel_16(r));
} else {
write_noninterlaced(write_gray_pixel_8(r));
}
xfree(row);
} else {
- if (png_get_image_height(png_p, info_p) *
- png_get_rowbytes(png_p, info_p) >= 10240000L)
- luatex_warn
- ("large interlaced PNG might cause out of memory (use non-interlaced PNG to fix this)");
+ if (png_get_image_height(png_p, info_p) * png_get_rowbytes(png_p, info_p) >= 10240000L) {
+ formatted_warning("pngwrite","large interlaced bitmap might cause out of memory");
+ }
rows = xtalloc(png_get_image_height(png_p, info_p), png_bytep);
- for (i = 0; i < (int) png_get_image_height(png_p, info_p); i++)
+ for (i = 0; i < (int) png_get_image_height(png_p, info_p); i++) {
rows[i] = xtalloc(png_get_rowbytes(png_p, info_p), png_byte);
+ }
png_read_image(png_p, rows);
- if ((png_get_bit_depth(png_p, info_p) == 16)
- && (pdf->image_hicolor != 0)) {
+ if ((png_get_bit_depth(png_p, info_p) == 16) && (pdf->image_hicolor != 0)) {
write_interlaced(write_gray_pixel_16(row));
} else {
write_interlaced(write_gray_pixel_8(row));
@@ -317,33 +321,29 @@ static void write_png_rgb_alpha(PDF pdf, image_dict * idict)
int smask_size = 0;
smask_objnum = pdf_create_obj(pdf, obj_type_others, 0);
pdf_dict_add_ref(pdf, "SMask", (int) smask_objnum);
- smask_size =
- (int) ((png_get_rowbytes(png_p, info_p) / 4) *
- png_get_image_height(png_p, info_p));
+ smask_size = (int) ((png_get_rowbytes(png_p, info_p) / 4) * png_get_image_height(png_p, info_p));
smask = xtalloc((unsigned) smask_size, png_byte);
pdf_dict_add_streaminfo(pdf);
pdf_end_dict(pdf);
pdf_begin_stream(pdf);
if (png_get_interlace_type(png_p, info_p) == PNG_INTERLACE_NONE) {
row = xtalloc(png_get_rowbytes(png_p, info_p), png_byte);
- if ((png_get_bit_depth(png_p, info_p) == 16)
- && (pdf->image_hicolor != 0)) {
+ if ((png_get_bit_depth(png_p, info_p) == 16) && (pdf->image_hicolor != 0)) {
write_noninterlaced(write_rgb_pixel_16(r));
} else {
write_noninterlaced(write_rgb_pixel_8(r));
}
xfree(row);
} else {
- if (png_get_image_height(png_p, info_p) *
- png_get_rowbytes(png_p, info_p) >= 10240000L)
- luatex_warn
- ("large interlaced PNG might cause out of memory (use non-interlaced PNG to fix this)");
+ if (png_get_image_height(png_p, info_p) * png_get_rowbytes(png_p, info_p) >= 10240000L) {
+ formatted_warning("pngwrite","large interlaced bitmap might cause out of memory");
+ }
rows = xtalloc(png_get_image_height(png_p, info_p), png_bytep);
- for (i = 0; i < (int) png_get_image_height(png_p, info_p); i++)
+ for (i = 0; i < (int) png_get_image_height(png_p, info_p); i++) {
rows[i] = xtalloc(png_get_rowbytes(png_p, info_p), png_byte);
+ }
png_read_image(png_p, rows);
- if ((png_get_bit_depth(png_p, info_p) == 16)
- && (pdf->image_hicolor != 0)) {
+ if ((png_get_bit_depth(png_p, info_p) == 16) && (pdf->image_hicolor != 0)) {
write_interlaced(write_rgb_pixel_16(row));
} else {
write_interlaced(write_rgb_pixel_8(row));
@@ -373,8 +373,9 @@ the ``PNG Copy'' function must be skipped; therefore the lengthy tests.
static int spng_getint(FILE * f)
{
unsigned char buf[4];
- if (fread(buf, 1, 4, f) != 4)
- luatex_fail("writepng: reading chunk type failed");
+ if (fread(buf, 1, 4, f) != 4) {
+ normal_error("writepng", "reading chunk type failed");
+ }
return ((((((int) buf[0] << 8) + buf[1]) << 8) + buf[2]) << 8) + buf[3];
}
@@ -395,7 +396,7 @@ static void copy_png(PDF pdf, image_dict * idict)
f = (FILE *) png_get_io_ptr(png_p);
/* 1st pass to find overall stream /Length */
if (fseek(f, 8, SEEK_SET) != 0)
- luatex_fail("writepng: fseek in PNG file failed (1)");
+ normal_error("writepng", "fseek in file failed");
do {
len = spng_getint(f);
type = spng_getint(f);
@@ -406,49 +407,52 @@ static void copy_png(PDF pdf, image_dict * idict)
case SPNG_CHUNK_IDAT:
streamlength += len;
default:
- if (fseek(f, len + 4, SEEK_CUR) != 0)
- luatex_fail("writepng: fseek in PNG file failed (2)");
+ if (fseek(f, len + 4, SEEK_CUR) != 0) {
+ normal_error("writepng", "fseek in file failed");
+ }
}
} while (endflag == false);
pdf_dict_add_int(pdf, "Length", streamlength);
pdf_dict_add_name(pdf, "Filter", "FlateDecode");
pdf_add_name(pdf, "DecodeParms");
pdf_begin_dict(pdf);
- pdf_dict_add_int(pdf, "Colors",
- png_get_color_type(png_p,
- info_p) == PNG_COLOR_TYPE_RGB ? 3 : 1);
+ pdf_dict_add_int(pdf, "Colors", png_get_color_type(png_p,info_p) == PNG_COLOR_TYPE_RGB ? 3 : 1);
pdf_dict_add_int(pdf, "Columns", png_get_image_width(png_p, info_p));
pdf_dict_add_int(pdf, "BitsPerComponent", png_get_bit_depth(png_p, info_p));
pdf_dict_add_int(pdf, "Predictor", 10);
pdf_end_dict(pdf);
pdf_end_dict(pdf);
pdf_begin_stream(pdf);
- assert(pdf->zip_write_state == NO_ZIP); /* the PNG stream is already compressed */
+ assert(pdf->zip_write_state == NO_ZIP); /* the PNG stream is already compressed */
/* 2nd pass to copy data */
endflag = false;
if (fseek(f, 8, SEEK_SET) != 0)
- luatex_fail("writepng: fseek in PNG file failed (3)");
+ normal_error("writepng", "fseek in file failed");
do {
len = spng_getint(f);
type = spng_getint(f);
switch (type) {
- case SPNG_CHUNK_IDAT: /* do copy */
- if (idat == 2)
- luatex_fail("writepng: IDAT chunk sequence broken");
+ case SPNG_CHUNK_IDAT:
+ /* do copy */
+ if (idat == 2) {
+ normal_error("writepng", "IDAT chunk sequence broken");
+ }
idat = 1;
- if (read_file_to_buf(pdf, f, len) != len)
- luatex_fail("writepng: fread failed");
- if (fseek(f, 4, SEEK_CUR) != 0)
- luatex_fail("writepng: fseek in PNG file failed (4)");
+ if (read_file_to_buf(pdf, f, len) != len) {
+ normal_error("writepng", "fread failed");
+ } else if (fseek(f, 4, SEEK_CUR) != 0) {
+ normal_error("writepng", "fseek in file failed");
+ }
break;
- case SPNG_CHUNK_IEND: /* done */
+ case SPNG_CHUNK_IEND:
+ /* done */
endflag = true;
break;
default:
if (idat == 1)
idat = 2;
if (fseek(f, len + 4, SEEK_CUR) != 0)
- luatex_fail("writepng: fseek in PNG file failed (5)");
+ normal_error("writepng", "fseek in file failed");
}
} while (endflag == false);
pdf_end_stream(pdf);
@@ -463,10 +467,14 @@ static void reopen_png(image_dict * idict)
height = img_ysize(idict);
xres = img_xres(idict);
yres = img_yres(idict);
- read_png_info(idict, IMG_KEEPOPEN);
- if (width != img_xsize(idict) || height != img_ysize(idict)
- || xres != img_xres(idict) || yres != img_yres(idict))
- luatex_fail("writepng: image dimensions have changed");
+ /*
+ we need to ake sure that the file kept open
+ */
+ img_keepopen(idict) = 1;
+ read_png_info(idict);
+ if (width != img_xsize(idict) || height != img_ysize(idict) || xres != img_xres(idict) || yres != img_yres(idict)) {
+ normal_error("writepng", "image dimensions have changed");
+ }
}
@ @c
@@ -526,53 +534,51 @@ void write_png(PDF pdf, image_dict * idict)
/* reset structure */
(void) png_set_interlace_handling(png_p);
png_read_update_info(png_p, info_p);
-
pdf_begin_obj(pdf, img_objnum(idict), OBJSTM_NEVER);
pdf_begin_dict(pdf);
pdf_dict_add_name(pdf, "Type", "XObject");
pdf_dict_add_name(pdf, "Subtype", "Image");
pdf_dict_add_img_filename(pdf, idict);
- if (img_attr(idict) != NULL && strlen(img_attr(idict)) > 0)
+ if (img_attr(idict) != NULL && strlen(img_attr(idict)) > 0) {
pdf_printf(pdf, "\n%s\n", img_attr(idict));
+ }
pdf_dict_add_int(pdf, "Width", (int) png_get_image_width(png_p, info_p));
pdf_dict_add_int(pdf, "Height", (int) png_get_image_height(png_p, info_p));
- pdf_dict_add_int(pdf, "BitsPerComponent",
- (int) png_get_bit_depth(png_p, info_p));
+ pdf_dict_add_int(pdf, "BitsPerComponent", (int) png_get_bit_depth(png_p, info_p));
if (img_colorspace(idict) != 0) {
pdf_dict_add_ref(pdf, "ColorSpace", (int) img_colorspace(idict));
} else {
switch (png_get_color_type(png_p, info_p)) {
- case PNG_COLOR_TYPE_PALETTE:
- png_get_PLTE(png_p, info_p, &palette, &num_palette);
- palette_objnum = pdf_create_obj(pdf, obj_type_others, 0);
- pdf_add_name(pdf, "ColorSpace");
- pdf_begin_array(pdf);
- pdf_add_name(pdf, "Indexed");
- pdf_add_name(pdf, "DeviceRGB"); /* base; PDFRef. 4.5.5 */
- pdf_add_int(pdf, (int) (num_palette - 1)); /* hival */
- pdf_add_ref(pdf, (int) palette_objnum); /* lookup */
- pdf_end_array(pdf);
- break;
- case PNG_COLOR_TYPE_GRAY:
- case PNG_COLOR_TYPE_GRAY_ALPHA:
- pdf_dict_add_name(pdf, "ColorSpace", "DeviceGray");
- break;
- case PNG_COLOR_TYPE_RGB:
- case PNG_COLOR_TYPE_RGB_ALPHA:
- pdf_dict_add_name(pdf, "ColorSpace", "DeviceRGB");
- break;
- default:
- luatex_fail("unsupported type of color_type <%i>",
- png_get_color_type(png_p, info_p));
+ case PNG_COLOR_TYPE_PALETTE:
+ png_get_PLTE(png_p, info_p, &palette, &num_palette);
+ palette_objnum = pdf_create_obj(pdf, obj_type_others, 0);
+ pdf_add_name(pdf, "ColorSpace");
+ pdf_begin_array(pdf);
+ pdf_add_name(pdf, "Indexed");
+ pdf_add_name(pdf, "DeviceRGB"); /* base; PDFRef. 4.5.5 */
+ pdf_add_int(pdf, (int) (num_palette - 1)); /* hival */
+ pdf_add_ref(pdf, (int) palette_objnum); /* lookup */
+ pdf_end_array(pdf);
+ break;
+ case PNG_COLOR_TYPE_GRAY:
+ case PNG_COLOR_TYPE_GRAY_ALPHA:
+ pdf_dict_add_name(pdf, "ColorSpace", "DeviceGray");
+ break;
+ case PNG_COLOR_TYPE_RGB:
+ case PNG_COLOR_TYPE_RGB_ALPHA:
+ pdf_dict_add_name(pdf, "ColorSpace", "DeviceRGB");
+ break;
+ default:
+ formatted_error("writepng", "unsupported color_type '%i'", png_get_color_type(png_p, info_p));
}
}
- if (png_copy && pdf->minor_version > 1
+ if (png_copy
+ && pdf->minor_version > 1
&& png_get_interlace_type(png_p, info_p) == PNG_INTERLACE_NONE
&& (png_get_color_type(png_p, info_p) == PNG_COLOR_TYPE_GRAY
- || png_get_color_type(png_p, info_p) == PNG_COLOR_TYPE_RGB)
+ || png_get_color_type(png_p, info_p) == PNG_COLOR_TYPE_RGB)
&& !pdf->image_apply_gamma
- && (!png_get_valid(png_p, info_p, PNG_INFO_gAMA)
- || int_file_gamma == PNG_FP_1)
+ && (!png_get_valid(png_p, info_p, PNG_INFO_gAMA) || int_file_gamma == PNG_FP_1)
&& !png_get_valid(png_p, info_p, PNG_INFO_cHRM)
&& !png_get_valid(png_p, info_p, PNG_INFO_iCCP)
&& !png_get_valid(png_p, info_p, PNG_INFO_sBIT)
@@ -583,64 +589,63 @@ void write_png(PDF pdf, image_dict * idict)
&& !png_get_valid(png_p, info_p, PNG_INFO_sPLT)) {
copy_png(pdf, idict);
} else {
- if (0) {
- tex_printf(" *** PNG copy skipped because: ");
+ if (img_errorlevel(idict) > 1) {
if (!png_copy)
- tex_printf("!png_copy ");
+ normal_warning("pngcopy","failed");
if (!(pdf->minor_version > 1))
- tex_printf("minorversion=%d ", pdf->minor_version);
+ formatted_warning("pngcopy","skipped because minorversion is '%d'", pdf->minor_version);
if (!(png_get_interlace_type(png_p, info_p) == PNG_INTERLACE_NONE))
- tex_printf("interlaced ");
+ normal_warning("pngcopy","skipped because of interlacing");
if (!((png_get_color_type(png_p, info_p) == PNG_COLOR_TYPE_GRAY)
- || (png_get_color_type(png_p, info_p) == PNG_COLOR_TYPE_RGB)))
- tex_printf("colortype ");
+ || (png_get_color_type(png_p, info_p) == PNG_COLOR_TYPE_RGB)))
+ normal_warning("pngcopy","skipped because of colortype");
if (pdf->image_apply_gamma)
- tex_printf("apply gamma ");
- if (!(!png_get_valid(png_p, info_p, PNG_INFO_gAMA)
- || int_file_gamma == PNG_FP_1))
- tex_printf("gamma ");
+ normal_warning("pngcopy","skipped because of gamma (1)");
+ if (!(!png_get_valid(png_p, info_p, PNG_INFO_gAMA) || int_file_gamma == PNG_FP_1))
+ normal_warning("pngcopy","skipped because of gamma (2)");
if (png_get_valid(png_p, info_p, PNG_INFO_cHRM))
- tex_printf("cHRM ");
+ normal_warning("pngcopy","skipped because of cHRM");
if (png_get_valid(png_p, info_p, PNG_INFO_iCCP))
- tex_printf("iCCP ");
+ normal_warning("pngcopy","skipped because of iCCP");
if (png_get_valid(png_p, info_p, PNG_INFO_sBIT))
- tex_printf("sBIT ");
+ normal_warning("pngcopy","skipped because of sBIT");
if (png_get_valid(png_p, info_p, PNG_INFO_sRGB))
- tex_printf("sRGB ");
+ normal_warning("pngcopy","skipped because of sRGB");
if (png_get_valid(png_p, info_p, PNG_INFO_bKGD))
- tex_printf("bKGD ");
+ normal_warning("pngcopy","skipped because of bKGD");
if (png_get_valid(png_p, info_p, PNG_INFO_hIST))
- tex_printf("hIST ");
+ normal_warning("pngcopy","skipped because of hIST");
if (png_get_valid(png_p, info_p, PNG_INFO_tRNS))
- tex_printf("tRNS ");
+ normal_warning("pngcopy","skipped because of tRNS");
if (png_get_valid(png_p, info_p, PNG_INFO_sPLT))
- tex_printf("sPLT ");
+ normal_warning("pngcopy","skipped because of sPLT");
}
switch (png_get_color_type(png_p, info_p)) {
- case PNG_COLOR_TYPE_PALETTE:
- case PNG_COLOR_TYPE_GRAY:
- case PNG_COLOR_TYPE_RGB:
- write_png_gray(pdf, idict);
- break;
- case PNG_COLOR_TYPE_GRAY_ALPHA:
- if (pdf->minor_version >= 4) {
- write_png_gray_alpha(pdf, idict);
- last_png_needs_page_group = true;
- } else
+ case PNG_COLOR_TYPE_PALETTE:
+ case PNG_COLOR_TYPE_GRAY:
+ case PNG_COLOR_TYPE_RGB:
write_png_gray(pdf, idict);
- break;
- case PNG_COLOR_TYPE_RGB_ALPHA:
- if (pdf->minor_version >= 4) {
- write_png_rgb_alpha(pdf, idict);
- last_png_needs_page_group = true;
- } else
- write_png_gray(pdf, idict);
- break;
- default:
- assert(0);
+ break;
+ case PNG_COLOR_TYPE_GRAY_ALPHA:
+ if (pdf->minor_version >= 4) {
+ write_png_gray_alpha(pdf, idict);
+ last_png_needs_page_group = true;
+ } else
+ write_png_gray(pdf, idict);
+ break;
+ case PNG_COLOR_TYPE_RGB_ALPHA:
+ if (pdf->minor_version >= 4) {
+ write_png_rgb_alpha(pdf, idict);
+ last_png_needs_page_group = true;
+ } else
+ write_png_gray(pdf, idict);
+ break;
+ default:
+ assert(0);
}
}
write_palette_streamobj(pdf, palette_objnum, palette, num_palette);
+ /* always */
close_and_cleanup_png(idict);
}
@@ -649,13 +654,15 @@ static boolean transparent_page_group_was_written = false;
@ Called after the xobject generated by |write_png| has been finished; used to
write out additional objects
+
@c
void write_additional_png_objects(PDF pdf)
{
(void) pdf;
(void) transparent_page_group;
(void) transparent_page_group_was_written;
- return; /* this interferes with current macro-based usage and cannot be configured */
+ return;
+ /* this interferes with current macro-based usage and cannot be configured */
#if 0
if (last_png_needs_page_group) {
if (!transparent_page_group_was_written && transparent_page_group > 1) {