Taher, we've answered directly via support with more detail. However, for those reading, a general summary of the comments are as follows:
_______________________________
a. Are transparent images supported?
As you may be aware, there are a few different ways of specifying transparency in PNG images.
The Options parameter of the AddImageFromFile function has a few useful values for PNG images:
0 = Load the image as usual 1 = Load the alpha channel as a greyscale image 2 = Load the image and alpha channel (limit alpha to 8-bit) 3 = Load the image (limit image 8-bit/channel) 4 = Load the alpha channel (limit to 8-bit/channel) 5 = Load the image with alpha channel (limit both to 8-bit/channel) 6 = Load the image and alpha channel
You would need to select an option that includes both the image and the alpha channel, so that would be 2, 5 or 6.
The choice depends on the bit depth of your source images. Some PDF viewers/processors might not be able to handle 16-bit image data for the image and/or for the alpha channel. Option 5 would be the safest, option 6 would provide the best image quality if the source had 16-bit data, and option 2 is a trade off with the image data allowed to be 16-bit while forcing only the alpha channel to 8-bit if necessary.
Internally, QPL will separate the alpha channel and the image data and create two separate PDF image objects, linked with an SMask (soft mask) entry.
You can then continue to use the image drawing functions as usual and the transparent areas will come through automatically.
Here's a quick example:
QP.DrawLine(0, 0, QP.PageWidth, QP.PageHeight); QP.AddImageFromFile("scfloral10.png", 2); QP.DrawImage(0, QP.PageHeight, QP.PageWidth, QP.PageHeight); QP.SaveToFile("scfloral10.pdf");
______________
Transparency in GIF and TIFF images is not currently supported by QPL. We are constantly improving the image handling ability of the library but it's difficult to provide a time estimate for this.
______________
Regarding white/backgrounds -- in your sample DesignCMYK.pdf file the existing image has a solid white background. So the trick is to set up a transparency mask on the original image first, and then draw the new image onto a new layer behind the existing page content. Here's a quick sample showing how this could be done:
// Load the original file QP.LoadFromFile("DesignCMYK.pdf");
// Locate the existing image in the document QP.FindImages;
// Select the found image QP.SelectImage(QP.GetImageID(1));
// Set the image mask - white QP.SetImageMaskCMYK(0, 0, 0, 0, 0, 0, 0, 0);
// Create a separate layer for the new image QP.NewLayer; QP.AddImageFromFile("scfloral10.png", 0);
// Draw the new image QP.DrawImage(0, QP.PageHeight / 2, QP.PageWidth / 2, QP.PageHeight / 2);
// Move the new layer to the back QP.MoveLayer(QP.LayerCount, 1);
// Save the combined file QP.SaveToFile("DesignCMYK-out.pdf");
|