PngImage Constructor (PngOptions, Int32, Int32) |
Namespace: Aspose.Imaging.FileFormats.Png
[C#] string dir = "c:\\temp\\"; Aspose.Imaging.ImageOptions.PngOptions createOptions = new Aspose.Imaging.ImageOptions.PngOptions(); // The number of bits per color channel createOptions.BitDepth = 8; // Each pixel is a (red, green, blue) triple followed by the alpha component. createOptions.ColorType = Imaging.FileFormats.Png.PngColorType.TruecolorWithAlpha; // The maximum level of compression. createOptions.CompressionLevel = 9; // Usage of filters allows to compress continuous tonal images more effectively. createOptions.FilterType = Aspose.Imaging.FileFormats.Png.PngFilterType.Sub; // Use progressive loading createOptions.Progressive = true; // Create a PNG image with custom parameters. using (Aspose.Imaging.FileFormats.Png.PngImage pngImage = new Aspose.Imaging.FileFormats.Png.PngImage(createOptions, 100, 100)) { Aspose.Imaging.Brushes.LinearGradientBrush gradientBrush = new Aspose.Imaging.Brushes.LinearGradientBrush( new Aspose.Imaging.Point(0, 0), new Aspose.Imaging.Point(pngImage.Width, pngImage.Height), Aspose.Imaging.Color.Blue, Aspose.Imaging.Color.Transparent); Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(pngImage); // Fill the image with a semi-transparent gradient. graphics.FillRectangle(gradientBrush, pngImage.Bounds); // Save to a file. pngImage.Save(dir + "output.explicitoptions.png"); }