PngImage Constructor (Int32, Int32, PngColorType)
Initializes a new instance of the PngImage class.

Namespace: Aspose.Imaging.FileFormats.Png
Assembly: Aspose.Imaging (in Aspose.Imaging.dll) Version: 21.04
public PngImage(
	int width,
	int height,
	PngColorType colorType


Type: SystemInt32
The width.
Type: SystemInt32
The height.
Type: Aspose.Imaging.FileFormats.PngPngColorType
The color type.
This example shows how to create a PNG image of the specified size with the specified color type, fill it with a solid color and save it to a file.

string dir = "c:\\temp\\";

// Create a grayscale PNG image of 100x100 px.
// All colors will be automatically converted to the grayscale format.
using (Aspose.Imaging.FileFormats.Png.PngImage pngImage = new Aspose.Imaging.FileFormats.Png.PngImage(100, 100, Aspose.Imaging.FileFormats.Png.PngColorType.Grayscale))
    // Do some image processing, e.g. fill the entire image in red.
    Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(pngImage);
    Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
    graphics.FillRectangle(brush, pngImage.Bounds);

    // Save to a file.
    pngImage.Save(dir + "output.grayscale.png");
See Also