BmpImage Constructor (Int32, Int32, UInt16, IColorPalette, 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(
	int width,
	int height,
	ushort bitsPerPixel,
	IColorPalette palette,
	BitmapCompression compression,
	double horizontalResolution,
	double verticalResolution
)

Parameters

width
Type: SystemInt32
The image width.
height
Type: SystemInt32
The image height.
bitsPerPixel
Type: SystemUInt16
The bits per pixel.
palette
Type: Aspose.ImagingIColorPalette
The color palette.
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
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 create a BmpImage using various options.
[C#]

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

Aspose.Imaging.Color[] paletterColors = new Aspose.Imaging.Color[]
{
    Aspose.Imaging.Color.Red,
    Aspose.Imaging.Color.Green,
};

// Create a monochrome palette which contains only red and green colors.
Aspose.Imaging.IColorPalette palette = new Aspose.Imaging.ColorPalette(paletterColors);

// Create a monochrome 1-bpp BMP image of 100 x 100 px.
// The horizontal and vertical resolution will be set to 96 dpi.
using (Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = new Aspose.Imaging.FileFormats.Bmp.BmpImage(100, 100, 1, palette, Aspose.Imaging.FileFormats.Bmp.BitmapCompression.Rgb, 96.0, 96.0))
{
    Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(bmpImage);

    // Fill the upper half of the image in red.
    Aspose.Imaging.Brushes.SolidBrush redBrush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
    gr.FillRectangle(redBrush, new Aspose.Imaging.Rectangle(0, 0, bmpImage.Width, bmpImage.Height / 2));

    // Fill the lower half of the image in green.
    Aspose.Imaging.Brushes.SolidBrush greenBrush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Green);
    gr.FillRectangle(greenBrush, new Aspose.Imaging.Rectangle(0, bmpImage.Height / 2, bmpImage.Width, bmpImage.Height / 2));

    // Save to a BMP file
    bmpImage.Save(dir + "output.monochrome.96dpi.bmp");
}
See Also