PngImage Constructor (RasterImage)
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(
	RasterImage rasterImage
)

Parameters

rasterImage
Type: Aspose.ImagingRasterImage
The raster image.
Examples
This example shows how to load PNG image from a BMP image.
[C#]

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

// Load a TrueColor PNG image from a BMP image.
// First, create a temporal BMP image that will be a foundation for building a PNG image.
// You can also load BMP image from a file or use an image of any other raster format.
using (Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = new Aspose.Imaging.FileFormats.Bmp.BmpImage(100, 100))
{
    // Fill the entire BMP image in red.
    Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(bmpImage);
    Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
    gr.FillRectangle(brush, bmpImage.Bounds);

    using (Aspose.Imaging.FileFormats.Png.PngImage pngImage = new Aspose.Imaging.FileFormats.Png.PngImage(bmpImage))
    {
        System.Console.WriteLine("The PNG color type: {0}", pngImage.GetOriginalOptions());
        pngImage.Save(dir + "output.png");
    }
}
See Also