BmpImage Constructor (RasterImage, UInt16, BitmapCompression, Double, Double)
Initializes a new instance of the BmpImage class.

Namespace: Aspose.Imaging.FileFormats.Bmp
Assembly: Aspose.Imaging (in Aspose.Imaging.dll) Version: 22.05
public BmpImage(
	RasterImage rasterImage,
	ushort bitsPerPixel,
	BitmapCompression compression,
	double horizontalResolution,
	double verticalResolution


Type: Aspose.ImagingRasterImage
The image to initialize pixel and palette data with.
Type: SystemUInt16
The bits per pixel.
Type: Aspose.Imaging.FileFormats.BmpBitmapCompression
The compression to use.
Type: SystemDouble
The horizontal resolution. Note due to the rounding the resulting resolution may slightly differ from the passed.
Type: SystemDouble
The vertical resolution. Note due to the rounding the resulting resolution may slightly differ from the passed.
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
The example shows how to load a BmpImage from another instance of RasterImage with the specified bit depth and compression.

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 24-bpp format if required.
    // The resolution will be set to 96 dpi.
    using (Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = new Aspose.Imaging.FileFormats.Bmp.BmpImage(rasterImage, 24, Aspose.Imaging.FileFormats.Bmp.BitmapCompression.Rgb, 96.0, 96.0))
        // Save to a BMP file
        bmpImage.Save(dir + "output.24bpp.96dpi.bmp");
See Also