WebPImage.HasAlpha
Contents
[
Hide
]WebPImage.HasAlpha property
Retrieve whether the image contains an alpha channel, indicating the presence of transparency information. Utilize this property to determine whether the image includes transparency, enabling appropriate handling and processing of alpha-related operations within your application.
public override bool HasAlpha { get; }
Property Value
The Has alpha channel.
Examples
The following example loads a WEBP image and prints information about raw data format and alpha channel.
[C#]
string dir = "c:\\temp\\";
string fileName = dir + "sample.webp";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(fileName))
{
Aspose.Imaging.FileFormats.Webp.WebPImage webpImage = (Aspose.Imaging.FileFormats.Webp.WebPImage)image;
// If the active TIFF frame has alpha channel, then the entire TIFF image is considered to have alpha channel.
System.Console.WriteLine("ImageFile={0}, FileFormat={1}, HasAlpha={2}", fileName, webpImage.RawDataFormat, webpImage.HasAlpha);
int i = 0;
foreach (Aspose.Imaging.FileFormats.Webp.IFrame frame in webpImage.Blocks)
{
Aspose.Imaging.FileFormats.Webp.WebPFrameBlock frameBlock = frame as Aspose.Imaging.FileFormats.Webp.WebPFrameBlock;
if (frameBlock != null)
{
System.Console.WriteLine("Frame={0}, FileFormat={1}, HasAlpha={2}", i++, frameBlock.RawDataFormat, frameBlock.HasAlpha);
}
}
}
// The output may look like this:
// ImageFile=c:\temp\sample.webp, FileFormat=RgbIndexed1Bpp, used channels: 1, HasAlpha=False
// Frame=0, FileFormat=RgbIndexed1Bpp, used channels: 1, HasAlpha=False
See Also
- class WebPImage
- namespace Aspose.Imaging.FileFormats.Webp
- assembly Aspose.Imaging