BmpImage Constructor (RasterImage)
Initializes a new instance of the BmpImage class.

Namespace: Aspose.Imaging.FileFormats.Bmp
Assembly: Aspose.Imaging (in Aspose.Imaging.dll) Version: 21.04
Syntax
public BmpImage(
	RasterImage rasterImage
)

Parameters

rasterImage
Type: Aspose.ImagingRasterImage
The image to initialize pixel and palette data with.
Exceptions
ExceptionCondition
ArgumentNullExceptionThe raster image cannot be null;rasterImage
BmpImageExceptionThe height should be positive.
ArgumentExceptionPalette should be specified for images with 8 bits per pixel or less.;palette
Examples
The example shows how to load a BmpImage from another instance of RasterImage.
[C#]

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

// Create a new PNG image.
Aspose.Imaging.ImageOptions.PngOptions createOptions = new Aspose.Imaging.ImageOptions.PngOptions();
createOptions.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream(), true);
using (Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Create(createOptions, 100, 100))
{
    // Fill the entire PNG image in red.
    Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(rasterImage);
    Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
    gr.FillRectangle(brush, rasterImage.Bounds);

    // Create a BMP image based on the PNG image.
    // The source pixels will be converted to 32-bpp format if required.
    using (Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = new Aspose.Imaging.FileFormats.Bmp.BmpImage(rasterImage))
    {
        // Save to a BMP file
        bmpImage.Save(dir + "output.32bpp.bmp");
    }
}
See Also