BmpImage Constructor (Stream, 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: 21.04
Syntax
public BmpImage(
	Stream stream,
	ushort bitsPerPixel,
	BitmapCompression compression,
	double horizontalResolution,
	double verticalResolution
)

Parameters

stream
Type: System.IOStream
The stream to load image from and initialize pixel and palette data with.
bitsPerPixel
Type: SystemUInt16
The bits per pixel.
compression
Type: Aspose.Imaging.FileFormats.BmpBitmapCompression
The compression to use.
horizontalResolution
Type: SystemDouble
The horizontal resolution. Note due to the rounding the resulting resolution may slightly differ from the passed.
verticalResolution
Type: SystemDouble
The vertical resolution. Note due to the rounding the resulting resolution may slightly differ from the passed.
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 a file stream with the specified bit depth and resolution.
[C#]

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

// Load a BMP image from a file stream.
// The source pixels will be converted to 24-bpp format if required.
// The resolution will be set to 96 dpi.
using (System.IO.Stream stream = System.IO.File.OpenRead(dir + "sample.bmp"))
{
    using (Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage =
        new Aspose.Imaging.FileFormats.Bmp.BmpImage(stream, 24, Aspose.Imaging.FileFormats.Bmp.BitmapCompression.Rgb, 96.0, 96.0))
    {
        // Do some image processing.
        // Save to another BMP file.
        bmpImage.Save(dir + "sample.output.24bpp.96dpi.bmp");
    }
}
See Also