Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Monday, April 2, 2007 2:15:52 PM(UTC)

wixy  
wixy

Groups: Registered
Posts: 8


I am using Lead Main Contol 13.0 as a component in a VB6 project

This is what I would like to do:
•Load a .tif file that is my background image into a lead control (not necessarily an single color as in the example).
•Load a .tif file that has a logo with transparent areas into another lead control.
•Combine the logo with the background so that the background shows everywhere the logo is transparent
•Save the file as a .tif file

When I load the logo into Photoshop – the bird is red with a white eye and black outline, the lettering is black – around the bird, and letters is transparent background

When I load the logo into the lead control and use the example code snippet to turn on bitmap transparency, some areas appear transparent – but they are not the same areas that appear transparent in Photoshop.

And when I combine the images, it doesn’t treat the background of the logo as transparent, regardless of the flags I use.

I have created a small example application and included the logo and background images I am using.

I would appreciate any help you can give me.

Thanks!!
File Attachment(s):
LogoTest.zip (525kb) downloaded 19 time(s).
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Sunday, April 8, 2007 7:59:07 AM(UTC)

Adnan Ismail  
Guest

Groups: Guests
Posts: 3,040

Was thanked: 1 time(s) in 1 post(s)




This image contains 4 unknown tags (Hex values 02BC, 8649, 8773
and 935C) that might be used to store the transparency information inside them.
LEADTOOLS does not recognize these tags because they are private to the application that created the image.


If you can have the transparency information stored in an
alpha channel instead, LEADTOOLS can load the alpha channel and you can use image processing function to utilize it in the combining process.

 
#3 Posted : Tuesday, April 10, 2007 1:53:45 PM(UTC)

wixy  
wixy

Groups: Registered
Posts: 8


I have saved the logo as a .tif with an alpha channel as suggested. Now, how do I get the logo to combine with the background image?

The logo is 32 bit (because it has the alpha channel). The background is 24 bit. These are the various combinations I have tried:

• Load the background
• Load the logo
• Raise the logo to 32 bit using ColorRes
• Combine the images
• Lead tools crashes


• Load the background
• Load the logo
• Lower the bits of the logo to 24 bit using ColorRes
• Combine the images
• Lead tools crashes


• Load the background
• Load the logo
• Set the bitmap of another lead control (leadLogoMask) to the bitmap alpha of the first
• Raise the bits of leadLogoMask to 24
• Combine the images using AlphaBlend
• Lower the bits of leadLogo to 24
• Try to combine the leadLogo in the same spot as the mask
• Lead tools crashes


Everytime lead tools crashes it shows the error: 20013 invalid parameter – which is the error I received when the bitmaps have differing bits-per-pixel.

I have tried various flags with call to ColorRes and even tried setting the BitmapAlpha = 0

attached you will find my test project with various iterations in the code and the logo and background I have been using.

Please help!!!!
File Attachment(s):
LogoTest2.zip (1,073kb) downloaded 18 time(s).
 
#4 Posted : Wednesday, April 11, 2007 12:00:07 PM(UTC)

GregR  
GregR

Groups: Registered, Tech Support, Administrators
Posts: 766


I made a few simple corrections to your sample.  I commented before each place I made an addition or modification.

1. Instead of doing a ColorRes on the images, I just loaded them in as 32 bits from the beginning
2. Used FeatherAlphaBlend instead of Combine and/or AlphaBlend

FeatherAlphaBlend is the only function we have available that actually does a true Alpha Channel implementation because is uses the 8bpp Alpha mask (which can be stored in BitmapAlpha as in my corrected sample) to combine the images.  Combine does not do any Transparency, and AlphaBlend simply applies an opacity factor.  FeatherAlphaBlend allows you to have variable opacities the way an Alpha channel is designed to work.

I've attached the corrected sample as well as a screenshot of my results.  Note that you will have to supply an unlock key for Digital Paint because FeatherAlphaBlend requires that ability.  Please contact sales@leadtools.com if you do not have this key.
File Attachment(s):
LogoTest2_corrected.zip (1,081kb) downloaded 22 time(s).
 
#5 Posted : Thursday, April 12, 2007 7:25:04 AM(UTC)

wixy  
wixy

Groups: Registered
Posts: 8


Thank you for your prompt response and efforts to help me find an answer to this frustrating problem.

I am doing multiple things with these images - I CANNOT LOAD them as 32 bit from the begining (or the middle, or the end)
the background images are in a library of existing 24 bit images that have various images combined with them along the way - the logo is the 2nd or 3rd step of 3-5 steps in compositing an image.

I don't really need the opacity value in the AlphaFeatherBlend and Alpha blend functions - I need to use the alpha channel as a MASK for the logo.

Once again - my goal is to:

Load the background into a Lead control
Load the logo into a Lead control
Copy the bitmap in the alpha channel into a second Lead as a mask
Combine the mask with an op_min flag
Combine the logo with an op_max flag
For example:

strPath = App.Path & "\logotest\"
iLogoHeight = 600
iLogoWidth = 600

leadBuilder.Load strPath & "blue frame.tif", 0, 0, 1
leadLogo.Load strPath & "cardinal logo alpha.tif", 0, 0, 1

leadLogoMask.Bitmap = leadLogo.BitmapAlpha
leadLogoMask.Size CDbl(iLogoWidth), CDbl(iLogoHeight), RESIZE_NORMAL
leadLogoMask.ColorRes 24, 0, 0, 0
leadBuilder.Combine 800, 200, iLogoWidth, iLogoHeight, leadLogoMask.Bitmap, 0, 0, CB_OP_MIN

leadLogo.Size CDbl(iLogoWidth), CDbl(iLogoHeight), RESIZE_NORMAL
leadLogo.ColorRes 24, 0, 0, 0
leadBuilder.Combine 800, 200, iLogoWidth, iLogoHeight, leadLogo.Bitmap, 0, 0, CB_OP_MAX

Fit leadBuilder



This call works:

leadBuilder.AlphaBlend 800, 200, iLogoWidth, iLogoHeight, leadLogoMask.Bitmap, 0, 0, 255

but this call gives me an error:

leadBuilder.Combine 800, 200, iLogoWidth, iLogoHeight, leadLogoMask.Bitmap, 0, 0, CB_OP_ADD



Why does the combine function not work with these images once they are changed to the same bits-per-pixel?
Is there any way to change my call to ColorRes to change the images so that they CAN be combined - (the resultant image in builder MUST end up 24 bits and able to combine with other images
Is there some other function I need to call to change the logo into a format that will Combine correctly with my background image?

Thanks for your time -
 
#6 Posted : Tuesday, April 17, 2007 4:27:41 AM(UTC)

GregR  
GregR

Groups: Registered, Tech Support, Administrators
Posts: 766


When you say "use the alpha channel as a mask", exactly what are you trying to do?  Could you create a diagram or piece together what you are hoping your end result will look like?

The alpha information in your file is just two different amounts of transparency.  Some of it is 100% transparent while another part is 100% opaque (0% transparent).  Are you simply trying to draw only the opaque part of the logo onto your background?  If so, then Combine is NOT the function you need to use.  To truly use Alpha channels, the only function you can use to combine images and alpha channels is FeatherAlphaBlend as I said before.


As for the Combine command and the error, even though you have done a ColorRes to make all the images the same bpp, you are using different flags and options when running the ColorRes.  I believe this is making some conflicts in palettes and is causing the errors.  Once I used the same flags and options for the ColorRest command on each main control, I ceased to get errors.  However, some of the colors changed and I'm not sure if the combination results are what you are going for, which is why I want you to explain in more detail what your goal is and what you really mean when you talk about the alpha mask.
 
#7 Posted : Thursday, April 19, 2007 3:02:52 PM(UTC)

wixy  
wixy

Groups: Registered
Posts: 8


>> When you say "use the alpha channel as a mask", exactly what are you trying to do?
I am trying to put the logo on a background so that the background shows around the logo and lettering.

>>The alpha information in your file is just two different amounts of transparency.
Yes, I know what an alpha channel is. And when it gets changed to a “regular” bitmap, it gets translated to a 8 bpp black and white image. And I want to change that to a 24 bpp black and white image that I can combine onto a 24 bpp background.

>>To truly use Alpha channels
I think I can use the information stored in the Alpha channel without “truly using” the alpha channel.

As I said, I am hoping to use the information as a mask. I have done this before (with lead controls) like this:
-- create a separate 24 bpp image “mask” in black and white – black where you want the image to show, white everywhere else
-- combine the mask with the background using CP_OP_MIN (which leaves black where I want the logo and the background image where the white was).
-- create the logo with black around it.
-- combine the logo into the same location using CP_OP_MAX (which lets the logo show where the black pixels were)

What I am trying to avoid is repeatedly loading 2 separate images - since a load takes longer than a combine and I am working with LOTS OF IMAGES and many different logos.

>>even though you have done a ColorRes to make all the images the same bpp, you are using different flags and options

I have tried several combinations of flags and options - combine crashes every time. If you would please help me figure out what flags to use with ColorRes to get combine to work, I can work on any palette conflicts.

Thanks again for your help,

 
#8 Posted : Monday, April 23, 2007 5:12:43 AM(UTC)

GregR  
GregR

Groups: Registered, Tech Support, Administrators
Posts: 766


I just used ColorRes 32, 0, 0, 0 for all three main controls (leadBuilder, leadLogo, & leadLogoMask) and it didn't crash for me.

You can try using the Min and Max, but as I said before, you should use FeatherAlphaBlend if you want to do Alpha right.

If your alpha channel basically boils down to a single transparent color, then you wouldn't need to use the alpha channel at all, nor would you need to load the image at 32 bpp or do any colorres'ing (most likely).  You could use SetRgnColor and use the L_RGN_SETNOT combine mode to select everything except for the transparent color.  Then when you call the regular combine method, it should only copy the selection you've made on the other image.
 
#9 Posted : Monday, April 23, 2007 6:56:35 AM(UTC)

wixy  
wixy

Groups: Registered
Posts: 8


>> You could use SetRgnColor and use the L_RGN_SETNOT combine mode to select everything except for the transparent color.

I thought about this approach. I have a wide variety of logos and will have more in the future. I am not sure how to pick one color to be the transparent color without limiting what can be used in logos in the future. (Obviously black and white are not an option) When I have edited bitmaps in the past, the transparent color seems to be a sort of teal green. I have been unable to find a standard for this – is there one?



>>I just used ColorRes 32, 0, 0, 0 for all three main controls (leadBuilder, leadLogo, & leadLogoMask) and it didn't crash for me.

As I said before, I need to combine the background and logo into a 24 bpp image – not 32. I used
ColorRes 24, 0, 0 for the leadLogo and leadMask - as well as some various combinations of other flags. Combine crashed every time. One more time I want to:

- Load the background as 24 bpp into leadBuilder
- load the logo as 32 bpp with an alpha channel into leadLogo
- load the alpha channel into leadLogoMask using leadLogoMask.Bitmap = leadLogo.BitmapAlpha
- change leadLogoMask to 24 bpp and combine
- change leadLogo to 24 bpp and combine.

If you could help be accomplish JUST THIS, I would be very grateful.

Again - thank you for your time.
 
#10 Posted : Tuesday, April 24, 2007 10:55:08 AM(UTC)

GregR  
GregR

Groups: Registered, Tech Support, Administrators
Posts: 766


Understandable about the region color.  You know your images better than me, but it was worth a try if it could work with your requirements.  Since your images vary too much, I agree that doing a simple combine with regions based on the color is not a good idea.

ColorRes 24, 0, 0, 0 also worked for me without crashing.  Maybe I wasn't as clear as I could have been earlier when I said that if you use the same ColorRes on each image it should work fine.  I would simply  make sure that your calls to ColorRes do not differ for your three images and I would bet that you will have success when you finally do the combines.

If you still have trouble with it, please put together a small sample project (NOT your entire applicatoin) that isolates the problem.  I know you've done this already, but we've both been working on this for a while, and your original project had a lot of junk code that was commented out.  Making a new one would ensure we're comparing apples to apples and that there is less clutter.
 
#11 Posted : Wednesday, April 25, 2007 9:36:43 AM(UTC)

wixy  
wixy

Groups: Registered
Posts: 8


Progress! Based on your comment

>>I would simply make sure that your calls to ColorRes do not differ for your three images.

When I called ColorRes on the base image:

leadBuilder.ColorRes 24, 0, 0, 0

before the combine, the combine worked - but messed up my palettes (as you mentioned). It is very important for me not to touch the palette of the base image - which is already 24 bpp.

Here is more information. We are a photoprocessing lab. All of our images are processed with the same programs and use standardized palettes. The background images and logos start out with the same palettes – so the call to ColorRes with 0 in the palette parameter must set the palette to some Lead default (??). What I want is for the Logo to take on the palette of the background image. I don’t care about the palette of the mask – since it is just black and white – but it seems as though it would also need to take on the palette of the background image before the combine will work. Can this be done?

Attached you will find a small sample program as requested.

Thanks again for your time,
File Attachment(s):
TestLogos.zip (1,072kb) downloaded 24 time(s).
 
#12 Posted : Monday, April 30, 2007 10:04:13 AM(UTC)

GregR  
GregR

Groups: Registered, Tech Support, Administrators
Posts: 766


I used these to keep the background blue. 

leadLogoMask.ColorRes 24, CRP_BYTEORDERBGR, 0, 0
leadLogo.ColorRes 24, CRP_BYTEORDERBGR, 0, 0

I believe that the default byte order when you used 24, 0, 0, 0 is RGB,
which would certainly cause color distortions if your image was
originally BGR.  Doing a ColorRes on the background like the ones below
had no affect, and consequently you don't need to run it at all since only doing the ColorRes on the logo and the mask kept it from throwing the Invalid Parameter Passed error.
 
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.

Powered by YAF.NET | YAF.NET © 2003-2020, Yet Another Forum.NET
This page was generated in 0.460 seconds.