LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Imagedit and transparent bits

Hello fellow CVI programmers,

Ive been playing with the ImageEdit example program supplied with CVI and I cant seem to get it to work. The problem is that the program can only edit bitmaps with a color depth of 8. All the images I have are of a color depth of 32. What Im trying to do is to read in a bitmap and make the background pixels transparent and draw the foreground on a transparent canvas using the mask feature.

Has anyone played around with this and have some example code please, or offer any solutions?

Many Thanks
Mike
0 Kudos
Message 1 of 2
(3,123 Views)
Hello,

The Imagedit example modifies the colors in the bitmap by manipulating the color table of the bitmap. The reason that the color table cannot be modified for bitmaps with a depth of greater that 8 bits is explained in the comments.

/* If the depth is > 8 bits, there is no color table for the
* image, so we dimm the controls. This program is not very useful
* in such cases. To edit the colors your display must be set to
* 8-bit depth or less.
*/
if(colorTableSize == 0) {
SetCtrlAttribute (panelHandle, PANEL_COLORTABLEINDEX, ATTR_DIMMED, 1);
SetCtrlAttribute (panelHandle, PANEL_COLORTABLEENTRY, ATTR_DIMMED, 1);
SetCtrlAttribute (panelHandle, PANEL_UPDATECOLORTABLE, ATTR_DIMMED, 1);
SetCtrlAttribute (panelHandle, PANEL_TEXTMSG_2, ATTR_DIMMED, 1);
return;
}

Additionally you can see in this web page titled Bitmap Format (.bmp) that there is no color table for bitmaps with high color depth. In these cases you will need to modify the individual pixel colors instead of modifying the entire color map.

Scott Y
NI
0 Kudos
Message 2 of 2
(3,083 Views)