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!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Support for Transparent images
  FAQ FAQ  Forum Search   Register Register  Login Login

Support for Transparent images

 Post Reply Post Reply
Author
Message
Taher View Drop Down
Beginner
Beginner
Avatar

Joined: 19 Jul 10
Location: Ireland
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote Taher Quote  Post ReplyReply Direct Link To This Post Topic: Support for Transparent images
    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




Back to Top
deabrew View Drop Down
Newbie
Newbie
Avatar

Joined: 19 Jan 09
Status: Offline
Points: 43
Post Options Post Options   Thanks (0) Thanks(0)   Quote deabrew Quote  Post ReplyReply Direct Link To This Post Posted: 24 Jul 10 at 2:53PM
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");

Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3529
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 24 Jul 10 at 5:31PM
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


Back to Top
Taher View Drop Down
Beginner
Beginner
Avatar

Joined: 19 Jul 10
Location: Ireland
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote Taher Quote  Post ReplyReply Direct Link To This Post Posted: 24 Jul 10 at 9:13PM
Thanks everyone...support guys have really been helpful ..top marks for quickpdf customer service and support personnel.


Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store