diff options
author | Martin Schröder <martin@oneiros.de> | 2008-03-23 16:38:33 +0000 |
---|---|---|
committer | Martin Schröder <martin@oneiros.de> | 2008-03-23 16:38:33 +0000 |
commit | 46b33fcf1608dbdc0e2f48761ae28d30fd520304 (patch) | |
tree | 72bc0f79bca1655628d163040b2348af836b9ed4 /Build/source/texk/web2c/pdftexdir/writepng.c | |
parent | 0e50747f61798f158b03612ae1e892fbe1e6d979 (diff) |
- import pdftex 1.40.8-alpha-20080323
- update xpdf to 3.02pl2
- update libpng to 1.2.25
git-svn-id: svn://tug.org/texlive/trunk@7095 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/pdftexdir/writepng.c')
-rw-r--r-- | Build/source/texk/web2c/pdftexdir/writepng.c | 63 |
1 files changed, 54 insertions, 9 deletions
diff --git a/Build/source/texk/web2c/pdftexdir/writepng.c b/Build/source/texk/web2c/pdftexdir/writepng.c index c8f9eb6fb9e..0b4ec4c1609 100644 --- a/Build/source/texk/web2c/pdftexdir/writepng.c +++ b/Build/source/texk/web2c/pdftexdir/writepng.c @@ -1,5 +1,5 @@ /* -Copyright (c) 1996-2007 Han The Thanh, <thanh@pdftex.org> +Copyright (c) 1996-2008 Han The Thanh, <thanh@pdftex.org> This file is part of pdfTeX. @@ -17,12 +17,14 @@ You should have received a copy of the GNU General Public License along with pdfTeX; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -$Id: writepng.c 152 2007-06-25 22:19:35Z ms $ +$Id$ */ #include "ptexlib.h" #include "image.h" +static int transparent_page_group = -1; + void read_png_info(integer img) { double gamma; @@ -87,6 +89,20 @@ void read_png_info(integer img) pdftex_fail("unsupported type of color_type <%i>", png_info(img)->color_type); } + if (fixedpdfminorversion >= 4 + && (png_info(img)->color_type == PNG_COLOR_TYPE_GRAY_ALPHA + || png_info(img)->color_type == PNG_COLOR_TYPE_RGB_ALPHA)) { + /* png with alpha channel in device colours; we have to add a Page + * Group to make Adobe happy, so we have to create a dummy group object + */ + if (transparent_page_group < 1) { + transparent_page_group = pdfnewobjnum(); + } + if (pdfpagegroupval < 1) { + pdfpagegroupval = transparent_page_group; + } + img_group_ref(img) = pdfpagegroupval; + } } @@ -471,12 +487,15 @@ void copy_png(integer img) } while (endflag == false); } +static boolean last_png_needs_page_group; + void write_png(integer img) { double gamma, checked_gamma; int i; integer palette_objnum = 0; + last_png_needs_page_group = false; if (fixedpdfminorversion < 5) fixedimagehicolor = 0; @@ -495,9 +514,13 @@ void write_png(integer img) } /* the switching between |png_info| and |png_ptr| queries has been trial and error. */ - 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) + if (fixedpdfminorversion > 1 + && png_info(img)->interlace_type == PNG_INTERLACE_NONE + && (png_ptr(img)->transformations == PNG_TRANSFORM_IDENTITY + || 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)) && (checked_gamma <= 1.01 && checked_gamma > 0.99) ) { @@ -562,18 +585,20 @@ void write_png(integer img) write_png_gray(img); break; case PNG_COLOR_TYPE_GRAY_ALPHA: - if (fixedpdfminorversion >= 4) + if (fixedpdfminorversion >= 4) { write_png_gray_alpha(img); - else + last_png_needs_page_group = true; + } else write_png_gray(img); break; case PNG_COLOR_TYPE_RGB: write_png_rgb(img); break; case PNG_COLOR_TYPE_RGB_ALPHA: - if (fixedpdfminorversion >= 4) + if (fixedpdfminorversion >= 4) { write_png_rgb_alpha(img); - else + last_png_needs_page_group = true; + } else write_png_rgb(img); break; default: @@ -583,3 +608,23 @@ void write_png(integer img) } pdfflush(); } + +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 */ +void write_additional_png_objects(void) +{ + if (last_png_needs_page_group) { + if (!transparent_page_group_was_written && transparent_page_group > 1) { + // create new group object + transparent_page_group_was_written = true; + pdfbeginobj(transparent_page_group, 2); + if (getpdfcompresslevel() == 0) { + pdf_puts("%PTEX Group needed for transparent pngs\n"); + } + pdf_puts("<</Type/Group /S/Transparency /CS/DeviceRGB /I true>>\n"); + pdfendobj(); + } + } +} |