Welcome to LEAD Support Forum Login | Register | Faq  

    LEAD Support Forum
  Resource to find answers and post technical questions about LEAD products.
Search    
   

PNG Files with Alpha Channel
Started by GregMcFarland at 03-25-2008 10:42. Topic has 7 replies.

Print Search « Previous Thread Next Thread »
  03-25-2008, 10:42
GregMcFarland is not online. Last active: 1/8/2008 2:51:43 PM GregMcFarland

Top 75 Posts
Joined on 11-08-2007
Posts 27
PNG Files with Alpha Channel
Reply Quote
I have what will probably turn out to be a simple question. I have a PNG file with a alpha channel transparency mask and am attempting to use the L_FeatherAlphaBlendBitmap() function to implement the transparency. My question is when loading the image I have the source PNG and can get the mask from the L_GetBitmapAlpha() function, what image do I use as the Destination bitmap in the L_FeatherAlphaBlendBitmap() function call? Do I simply need to create a blank image, or will this not work in all cases?
   Report 
  03-25-2008, 14:40
GregR is not online. Last active: 11/26/2008 3:40:25 PM GregR



Top 10 Posts
Joined on 05-31-2006
In House
Posts 1,717
Re: PNG Files with Alpha Channel
Reply Quote
Yes, you will need to create a destination image.  The easiest way to do this is to make a copy of your source image (L_CopyBitmap) and then fill it (L_FillBitmap) with whatever color you want for the background (generally the color of the form so the image appears to be transparent to the form).

Greg Ross
LEADTOOLS Technical Support
   Report 
  03-25-2008, 15:12
GregMcFarland is not online. Last active: 1/8/2008 2:51:43 PM GregMcFarland

Top 75 Posts
Joined on 11-08-2007
Posts 27
Re: PNG Files with Alpha Channel
Reply Quote
Greg, in my program I never know what the background of the final destination. Is there some easy way that I can create a region of the transparent area? I can't use the L_SetBitmapRgnFromMask() on the Alpha Channel generated mask can I?
   Report 
  03-26-2008, 9:43
GregR is not online. Last active: 11/26/2008 3:40:25 PM GregR



Top 10 Posts
Joined on 05-31-2006
In House
Posts 1,717
Re: PNG Files with Alpha Channel
Reply Quote
L_SetBitmapRgnFromMask() uses a 1bpp B/W mask.  The Alpha channel will be grayscale, so you'll need to flatten that image out and make it black and white if you want to use it with L_SetBitmapRgnFromMask.

Greg Ross
LEADTOOLS Technical Support
   Report 
  03-26-2008, 10:19
GregMcFarland is not online. Last active: 1/8/2008 2:51:43 PM GregMcFarland

Top 75 Posts
Joined on 11-08-2007
Posts 27
Re: PNG Files with Alpha Channel
Reply Quote
Is this the recommended method for acheiving the transparency from the alpha channel? Because the L_FeatherAlphaBlendBitmap() function takes two bitmaps and combines them using a mask but it does not allow you to paint the image with transparency.
   Report 
  03-26-2008, 10:37
GregR is not online. Last active: 11/26/2008 3:40:25 PM GregR



Top 10 Posts
Joined on 05-31-2006
In House
Posts 1,717
Re: PNG Files with Alpha Channel
Reply Quote
If your alpha channel only has 100% and 0% transparent and nothing else in between, then it will work.  Otherwise you still need to use L_FeatherAlphaBlendBitmap because it's the only function that works with alpha channels.

What exactly are you trying to accomplish?  Are you trying to make your entire form transparent?  What are the possible problems you're running into with using a background image?  Please explain in more detail.

Greg Ross
LEADTOOLS Technical Support
   Report 
  03-26-2008, 10:59
GregMcFarland is not online. Last active: 1/8/2008 2:51:43 PM GregMcFarland

Top 75 Posts
Joined on 11-08-2007
Posts 27
Re: PNG Files with Alpha Channel
Reply Quote
My application prints an bitmap on the page, however the image could lay on top of another item that was printed prior to the bitmap and is not a bitmap. Therefore I want to print my bitmap using the alpha channel and overlay the existing background inside the Device Context. Can I use the L_ScreenCaptureBitmap() to get the background for the region of interest? Does that work with printer Device Contexts as well? Thanks for your help.
   Report 
  03-26-2008, 13:27
GregR is not online. Last active: 11/26/2008 3:40:25 PM GregR



Top 10 Posts
Joined on 05-31-2006
In House
Posts 1,717
Re: PNG Files with Alpha Channel
Reply Quote
Thanks for the explanation.  Unfortunately this is not possible because as far as I know, there isn't a way to get the data from the DC and turn it into a bitmap.  The only thing that would work would be to do a screen capture, but that wouldn't work with printers.

Greg Ross
LEADTOOLS Technical Support
   Report 
Post
LEAD Support Fo... » Developer » File Formats » PNG Files with Alpha Channel

Powered by Community Server, by Telligent Systems