Do you own a Debenu Quick PDF Library 12/11/10/9/8/7? Upgrade to Debenu Quick PDF Library 13!

Foxit Quick PDF Library

Frequently Asked Question:

Return to FAQ Index

How do I add an image and make it transparent

Question

Hi,

I would like to draw a transparent image to a pdf document.

I've used the following methods but the image covers the text below it and is not transparent.

QP.AddImageFromVariant() QP.SelectPage() QP.DrawImage()

Answer

Quick PDF Library does support transparent images with a few different mechanisms.

The first method is using a color key mask with the functions SetImageMask and SetImageMaskCMYK. These functions add a range of colors to the image (starting RGB and ending RGB or starting CMYK and ending CMYK). When the image is drawn, any colors that are within the range will not be drawn - allowing the background through.

The second method is using the SetImageAsMask function. This works with 1-bit images only. When the image is drawn, all pixels with a value of 0 will be painted using the current fill color and all pixels with a value of 1 will be transparent. This is called a stencil mask.

The third method is using the SetImageAsMask function, this is called a soft mask. First, a grayscale image is added and the ImageID is stored by the programmer. Then, a main image is added and the SetImageAsMask function is called supplying the ImageID of the grayscale image. When the main image is drawn, each pixel will have a transparency value corresponding to the grayscale image's pixel values. For example, if an 8-bit grayscale soft mask image is used, there would be 256 possible transparency values.

Some images like GIF, TIFF and PNG contain an alpha channel directly or other transparency details directly inside the image.

At the moment Quick PDF Library supports reading the alpha channel only from PNG images. The Options parameter in functions like AddImageFromFile allows control over how the alpha channel is read.

If the PNG image contains only a fixed transparency setting rather than an alpha channel that is not yet supported by Quick PDF Library.

And transparent GIF and TIFF images are not yet supported either.


© 2015 Debenu & Foxit. All rights reserved. AboutBuyContactBlogNewsletterSupportFAQProduct UpdatesForum