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

Namespace: Aspose.Imaging.FileFormats.Png
Assembly: Aspose.Imaging (in Aspose.Imaging.dll) Version: 21.04
Syntax
public PngImage(
	string path,
	PngColorType colorType
)

Parameters

path
Type: SystemString
The path to load an image.
colorType
Type: Aspose.Imaging.FileFormats.PngPngColorType
The color type.
Exceptions
ExceptionCondition
ArgumentNullException
Examples
This example shows how to load a PNG image from a file with the specified color type.
[C#]

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

// Load a PNG image from a file.
// Note that the colorful image will be converted to grayscale automatically.
using (Aspose.Imaging.FileFormats.Png.PngImage pngImage = new Aspose.Imaging.FileFormats.Png.PngImage(dir + "sample.png", Aspose.Imaging.FileFormats.Png.PngColorType.Grayscale))
{
    // Save to a file.
    pngImage.Save(dir + "sample.grayscale.png");
}
See Also