ImageEn, unit imageenproc

TImageEnProc.CalcImageTransparency

TImageEnProc.CalcImageTransparency


Declaration

function CalcImageTransparency(MaxAlpha: Byte = 254): Double;


Description

Return the percentage of pixels that are transparent (partially or fully if MaxAlpha = 0).
Result will be value between 0 and 100.

Note: If the image PixelFormat is not ie1g or ie24RGB, it will be converted


Demo

Demo  Demos\ImageEditing\EveryMethod\EveryMethod.dpr


Examples

// Return percentage of pixels that are partially or fully transparent
d := ImageEnView1.Proc.CalcImageTransparency();
ShowMessage( format( 'Image has %d%% transparent pixels', [ Round( d )]));


// Return percentage of pixels that are fully transparent
d := ImageEnView1.Proc.CalcImageTransparency( 0 );
ShowMessage( format( 'Image has %d%% fully transparent pixels', [ Round( d )]));


// Load test image
ImageEnView1.IO.LoadFromFile( 'D:\TestImage.jpg' );

  

// Return the percentage of pixels that are partially or fully transparent
d := ImageEnView1.Proc.CalcImageTransparency();

ImageTest1.jpg: Image Transparency: 2%
ImageTest2.jpg: Image Transparency: 45%
ImageTest3.jpg: Image Transparency: 9%