LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Picture control transparency in CVI 8

I'm trying to use the new transparency features in CVI 8, but I'm having a little trouble figuring out how to use the new extended functions to accomplish what I want.  Ideally I would like to create an image in PaintShop with a transparent background and just paste it into the control.  It appears that CVI 8 still doesn't support that functionality.  If I can't do that, I would like to paste an image that uses a specific color as a substitute and then programmatically define that color as the transparent color.  Looking at the documentation for the new extended functions, it looks like I can't do that, either.
 
It appears that I have to suck the bitmap out of the control, define a mask based on the color I want to be transparent, create a new bitmap using GetBitmapEx, and load that new bitmap into the control.  Is there an easier way?
 
Tony Gray
0 Kudos
Message 1 of 6
(4,114 Views)
Hello Tony
 
Make sure to use PNG-format in you bitmap files.
I think PNG-format is the only fileformat to support transparency.
 
Jostein Bakken
0 Kudos
Message 2 of 6
(4,084 Views)

If you save the paintshop image in the .png image format (and it saves the transparency data), loading that file with CVI should work fine and preserve the transparency.

As far as the clipboard goes, it does not support transparency in images in a standard way. Different applications implement this in different ways and rarely interoperate well with each other. Images with transparency copied from within CVI should paste correctly into CVI, but that's probably all you should expect to work. Other applications will probably accept the image, just ignore the transparency.

It sounds like you are trying to just do binary transparency; is this right? If so, you do not need the new image functions in CVI, although the support for .png images may make it easier to get such an image into CVI. What CVI 8.0 introduced was partial (alpha-channel) transparency, along with the .png image format. The only other image format that supports any transparency is the .ico image format.

If you have any other questions about transparent images in CVI, I'll do my best to answer them.
 
Hope this helps, and best of luck,
 
-alex
0 Kudos
Message 3 of 6
(4,075 Views)

I tried your suggestions, but it didn't work.  I created a small image in Paintshop with a transparent background and painted a red X in it.  I saved it as a PNG file, then used the Load Image button in the picture control properties window to load the image.  The picture control is over a numeric control.  I excpected to see the numeric control, but it is covered by the picture control.

 

Am I missing something?

Tony

0 Kudos
Message 4 of 6
(4,068 Views)
Tony,
 
Did you paint the background of the picture control transparent? I tested this, and it seems to work fine. If you are creating the control programatically, you can set the ATTR_FRAME_COLOR attribute to VAL_TRANSPARENT.
 
-alex

Message Edited by Alex D on 03-31-2006 02:45 PM

0 Kudos
Message 5 of 6
(4,066 Views)
That did it!
 
 
It didn't occur to me to paint the control transparent when the file already was.  Thanks!  BTW, once I got it working with Load Image I tried to copy-and-paste from PS, and that didn't work.  Guess I'll just have to save the images to disk first. 
 
Tony
0 Kudos
Message 6 of 6
(4,059 Views)