PngImageHasAlpha Property |
Namespace: Aspose.Imaging.FileFormats.Png
[C#] // Get all supported PNG color types. System.Array colorTypes = System.Enum.GetValues(typeof(Aspose.Imaging.FileFormats.Png.PngColorType)); foreach (Aspose.Imaging.FileFormats.Png.PngColorType colorType in colorTypes) { Aspose.Imaging.ImageOptions.PngOptions createOptions = new Aspose.Imaging.ImageOptions.PngOptions(); createOptions.Source = new Sources.StreamSource(new System.IO.MemoryStream()); createOptions.ColorType = colorType; using (Aspose.Imaging.Image image = Image.Create(createOptions, 100, 100)) { Aspose.Imaging.FileFormats.Png.PngImage pngImage = (Aspose.Imaging.FileFormats.Png.PngImage)image; if (pngImage.HasAlpha) { System.Console.WriteLine("A {0} PNG image supports alpha channel", createOptions.ColorType); } else { System.Console.WriteLine("A {0} PNG image doesn't support alpha channel", createOptions.ColorType); } } } // The output looks like this: // A Grayscale PNG image doesn't support alpha channel // A Truecolor PNG image doesn't support alpha channel // A IndexedColor PNG image doesn't support alpha channel // A GrayscaleWithAlpha PNG image supports alpha channel // A TruecolorWithAlpha PNG image supports alpha channel