Implementing Transparency

You can implement transparency when doing any of the following:

Note: When loading an image file of any supported file format, LEADTOOLS ActiveX control will load the transparent color information into the BitmapTransparentColor property. You must set BitmapEnableTransparency property to TRUE for proper display. For example:

VB Example:

Dim value As Long
Dim Index As Long

'LEAD1.Load “c:\ltwin14x\images\Attention.gif”, 0, 0, 1

value = LEAD1.BitmapTransparentColor
'Account for the COLORREF, which can be a palette index or an RGB value
If value >= 16777216 Then ' Palette index
 Index = value - 16777216
 LEAD1.BitmapTransparentColor = LEAD1.BitmapPalette(Index)
Else ' RGB value
 LEAD1.BitmapTransparentColor = value
End If

LEAD1.BitmapEnableTransparency = True
LEAD1.ForceRepaint

Once a region is defined, you can create a mask from it, which you can save in the alpha channel of a 16- or 32-bit file. Refer to the BitmapAlpha property for an example of how to save a region in an alpha channel.

When specifying a transparent color, you can refer to a particular palette index, instead of the RGB value. This can be useful in cases where a color is used for transparency and the palette may contain the same color in more than one palette position.

When specifying a palette index as a color value, use the following formula:

16777216 + index

When evaluating a value to see if it is a palette index, you can use the following logic:

if value >= 16777216 then
index = value – 16777216