[NTG-pdftex] PNG handling, transparency

Hartmut Henkel hartmut_henkel at gmx.de
Mon Nov 1 21:45:20 CET 2004


On Mon, 1 Nov 2004, Hans Hagen wrote:

> Hartmut Henkel wrote:
>
> > Apart from this PNG opaque blending, there is also the
> > "Transparency" feature in PDF (PDF Ref. chapter 7). Looks
> > complicated. Has anybody ever played with transparency, e. g. by
> > some \pdfliteral tricks?
>
> sure, it's part of context for years already; one should build some
> additional resource dicts; i wonder if we have to go that way, since i
> always thought that transparency of bitmaps is a characteristic of the
> bitmaps image itself (so, i must look into it)

seems so yes: the alpha channel, if it would be properly extracted. Or
use a separate image, tried just the maybe most trivial case:

\pdfcompresslevel=0 \nopagenumbers
\immediate\pdfximage {mask.jpg}
\pdfximage attr {/SMask \number\pdflastximage\space 0 R} {img.jpg}
\leavevmode
\rlap{Hello}%
\rlap{\hbox{\pdfrefximage\pdflastximage}}\bye

The Hello shines through. Drawback: Seems that xpdf doesn't have any
idea of /SMask yet, the example works only with acroread and gs.

Instead of the mask.jpg, maybe here one could use the alpha component of
a PNG (instead of stripping alpha, so that the transparent PNG parts let
things shine through).

> preprocessing is ok, since doing that each run takes time as well; but
> then we must add an howto section to the manual
>
> how about transparent images on top of text

But there are so many special cases...

Regards, Hartmut


More information about the ntg-pdftex mailing list