10.07.2015 Views

Download - Multivac!

Download - Multivac!

Download - Multivac!

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

PDFlib supports three kinds of transparency information in images: implicit transparency,explicit transparency, and image masks.Note The mask must have the same orientation as the underlying image; otherwise it will be rejected.Since the orientation depends on the image file format and other factors it is difficult to detect.For this reason it is recommended to use the same file format and creation software forboth mask and image.Implicit transparency. In the implicit case, the transparency information from an externalimage file is respected, provided the image file format supports transparency oran alpha channel (this is not the case for all image file formats). Transparency informationis detected in the following image file formats:> GIF image files may contain a single transparent color value which is respected byPDFlib.> PNG image files may contain several flavors of transparency information, or a full alphachannel. PDFlib will retain single transparent color values; if multiple color valueswith an attached alpha value are given, only the first one with an alpha value below50 percent is used. A full alpha channel is ignored.Explicit transparency. The explicit case requires two steps, both of which involve imageoperations. First, a grayscale image must be prepared for later use as a transparencymask. This is accomplished by opening the image with the mask option. In PDF 1.3,which supports only 1-bit masks, using this option is required; in PDF 1.4 it is optional.The following kinds of images can be used for constructing a mask:> PNG images> TIFF images: the nopassthrough option for PDF_load_image( ) is recommended toavoid multi-strip images.> raw image dataPixel values of 0 (zero) in the mask will result in the corresponding area of the maskedimage being painted, while high pixel values result in the background shining through.If the pixel has more than 1 bit per pixel, intermediate values will blend the foregroundimage against the background, providing for a transparency effect. In the second stepthe mask is applied to another image which itself is acquired through one of the imagefunctions:mask = p.load_image("png", maskfilename, "mask");if (mask == -1)throw new Exception("Error: " + p.get_errmsg());String optlist = "masked " + mask;image = p.load_image(type, filename, optlist)if (image == -1)throw new Exception("Error: " + p.get_errmsg());p.fit_image(image, x, y, "");Note the different use of the option list for PDF_load_image( ): mask for defining a mask,and masked for applying a mask to another image.The image and the mask may have different pixel dimensions; the mask will automaticallybe scaled to the image’s size.126 Chapter 6: Importing Images and PDF Pages

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

Saved successfully!

Ooh no, something went wrong!