LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

import png to pixmap with transparency

How can I import a PNG and unflatten it to create a pixmap whilst maintaining transparency in the image?
 
Even though I save the image with transparent pixels, when I bring it into my picture control using the "Read PNG File" and "Unflatten to Pixmap" VIs the transparent pixels are replaced with white ones. Is it something to do with a mask?
 
Thanks.
0 Kudos
Message 1 of 9
(4,386 Views)
The picture control does not support alpha transparency, only a mask.

___________________
Try to take over the world!
0 Kudos
Message 2 of 9
(4,380 Views)

tst wrote:
The picture control does not support alpha transparency, only a mask.


You can convert alpha channel to mask using Create Mask By Alpha.vi
in vi.lib/picture/picture.llb
 
 
George Zou
 
George Zou
Message 3 of 9
(4,371 Views)
Can anyone help - perhaps with an example?
 
Do I need to take the mask of the image and then invert it, then create an alpha mask from this?
 
I can't see "Create Mask By Alpha.vi" in my version (7.1).
0 Kudos
Message 4 of 9
(4,368 Views)
If I could find a way to return the content of my base image in the pixels where my alpha mask is - then I could use that to generate an image that gave the illusion of transparency?
0 Kudos
Message 5 of 9
(4,358 Views)
The Image cluster, from read PNG.vi contains these info.
In the 24 bit image info the first byte is the alpha channel.

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 6 of 9
(4,349 Views)


russelldav wrote:
If I could find a way to return the content of my base image in the pixels where my alpha mask is - then I could use that to generate an image that gave the illusion of transparency?

To create a semi-transparent image, you can break each pixel into its RGB values, average these values with the RGB values of what's supposed to be under it and then build the result back into the 32 bit numbers. I assume that for alpha transparency, you will need to do averaging which will take the alpha value into account. To get the RGB value, you can go over the image a loop and use the color to RGB VI, but I'm pretty sure using the Split number function on the 2D U32 array twice will also get you the correct values.

___________________
Try to take over the world!
0 Kudos
Message 7 of 9
(4,343 Views)
Message 8 of 9
(4,334 Views)

TonP wrote:
The Image cluster, from read PNG.vi contains these info.
In the 24 bit image info the first byte is the alpha channel.

Ton

Only the 32 bit image has alpha channel.  The other 3 bytes are Red, Green, and Blue.
 
 
 
George Zou
0 Kudos
Message 9 of 9
(4,304 Views)