Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
![]() |
Support for Transparent images |
Post Reply ![]() |
Author | |
Taher ![]() Beginner ![]() ![]() Joined: 19 Jul 10 Location: Ireland Status: Offline Points: 2 |
![]() ![]() ![]() ![]() ![]() Posted: 19 Jul 10 at 4:00PM |
Hi Guys,
i have already sent this email to support but in a hurry to get a quick answer therefore posting it here as well.. a) Are transparent images supported ?, we are using png files with its background being transparent, however when we load them and start drawing into the PDF, it somehow converts the transparency into a white or black background. b) If its supported, can you please helps us with some code snippets. If it’s not supported , do you guys know if they plan to support it in the near future?, a time frame would really help us…? Thanks Regards Taher |
|
![]() |
|
deabrew ![]() Newbie ![]() ![]() Joined: 19 Jan 09 Status: Offline Points: 43 |
![]() ![]() ![]() ![]() ![]() |
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? 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"); |
|
![]() |
|
Ingo ![]() Moderator Group ![]() ![]() Joined: 29 Oct 05 Status: Offline Points: 3529 |
![]() ![]() ![]() ![]() ![]() |
Hi Taher!
Your questions are answered ... So there's only our warm welcome for you in this forum! It's a user-user-forum here. For special things you should contact the Debenu-guys (like Karl) directly. Cheers, Ingo |
|
![]() |
|
Taher ![]() Beginner ![]() ![]() Joined: 19 Jul 10 Location: Ireland Status: Offline Points: 2 |
![]() ![]() ![]() ![]() ![]() |
Thanks everyone...support guys have really been helpful ..top marks for quickpdf customer service and support personnel.
|
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store