17.05.2014 Views

PDFlib 8 Windows COM/.NET Tutorial

PDFlib 8 Windows COM/.NET Tutorial

PDFlib 8 Windows COM/.NET Tutorial

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Fig. 7.1<br />

Using a clipping path to separate<br />

foreground and background<br />

7.1.3 Clipping Paths<br />

<strong>PDFlib</strong> supports clipping paths in TIFF and JPEG images created with Adobe Photoshop.<br />

An image file may contain multiple named paths. Using the clippingpathname option of<br />

load_image( ) one of the named paths can be selected and will be used as a clipping path:<br />

only those parts of the image inside the clipping path will be visible, other parts will remain<br />

invisible. This is useful to separate background and foreground, eliminate unwanted<br />

portions of an image, etc.<br />

Alternatively, an image file may specify a default clipping path. If <strong>PDFlib</strong> finds a default<br />

clipping path in an image file it will automatically apply it to an image (see Figure<br />

7.1). In order to prevent the default clipping path from being applied set the honorclippingpath<br />

option in load_image( ) to false. If you have several instances of the same<br />

image and only some instances shall have the clipping path applied, you can supply the<br />

ignoreclippingpath option in fit_image( ) in order to disable the clipping path. When a<br />

clipping path is applied, the bounding box of the clipped image will be used as the basis<br />

for all calculations related to placing or fitting the image.<br />

Cookbook A full code sample can be found in the Cookbook topic images/integrated_clipping_path.<br />

7.1.4 Image Masks and Transparency<br />

<strong>PDFlib</strong> supports three kinds of transparency information in images: implicit transparency<br />

with alpha channels, explicit transparency, and image masks.<br />

Implicit transparency with alpha channels. Raster images may be partially transparent,<br />

i.e. the background shines through the image. This is useful, for example, to ignore<br />

the background of an image and display only the person or object in the foreground.<br />

Transparency information can be stored in a separate alpha channel or (in palettebased<br />

images) as a transparent palette entry. Transparent images are not allowed in<br />

PDF/A-1, PDF/X-1 and PDF/X-3. <strong>PDFlib</strong> processes transparency information in the following<br />

image formats:<br />

> GIF image files may contain a single transparent color value (palette entry) which is<br />

respected by <strong>PDFlib</strong>.<br />

> TIFF images may contain a single associated alpha channel which will be honored by<br />

<strong>PDFlib</strong>. Alternatively, a TIFF image may contain an arbitrary number of unassociated<br />

184 Chapter 7: Importing Images and PDF Pages (Edition for <strong>COM</strong>, .<strong>NET</strong>, and REALbasic)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!