MakeTransparent

<< Click to Display Table of Contents >>

Navigation:  EasyDotNet documentation > Classes > TDrawingBitmap > Methods >

MakeTransparent

Previous pageReturn to chapter overviewNext page

Makes the default transparent (or specified) color transparent for this Bitmap.

 

transparentColor - The value that represents the color to make transparent.

 

MakeTransparent                 PROCEDURE(LONG transparentColor = COLOR:NONE), BOOL, PROC

 

 

 

Makes every pixel transparent that is closer than delta to the target color. Only for bitmaps with Pixel format of Format::32bppArgb.

 

transparentColor - The value that represents the color to make transparent.

delta - The distance is the simple sum of the three channels' deltas.

 

MakeTransparent                 PROCEDURE(LONG transparentColor, LONG delta), BOOL, PROC

 

Example:

 

!- load opaque jpeg image

trnBitmap.FromFile('EDN_logo.jpg')

!- change pixel format to 32ARGB, only this format is compatible with MakeTransparent(color, delta).

!- JPEG format may have compression techniques that use a range of pixel colors in the background instead of a single color.

trnBitmap.PixelFormat(PixelFormat::32bppArgb) !-- allow transparency

!- make every pixel transparent that is closer than delta to the target color.

!- (The distance is the simple sum of the three channels' deltas..)

trnBitmap.MakeTransparent(COLOR:White, 20)

 

!- draw transparent image over our background image

ThisBitmap1.DrawImage(trnBitmap, 0, 0, ThisBitmap1.Width(), ThisBitmap1.Height())

!- show resulting image

ThisBitmap1.Show(?imgBitmap)