BmpImage Constructor (RasterImage, UInt16, BitmapCompression, Double, Double) |
Initializes a new instance of the
BmpImage class.
Namespace: Aspose.Imaging.FileFormats.BmpAssembly: Aspose.Imaging (in Aspose.Imaging.dll) Version: 22.05
Syntaxpublic BmpImage(
RasterImage rasterImage,
ushort bitsPerPixel,
BitmapCompression compression,
double horizontalResolution,
double verticalResolution
)
Public Sub New (
rasterImage As RasterImage,
bitsPerPixel As UShort,
compression As BitmapCompression,
horizontalResolution As Double,
verticalResolution As Double
)
public:
BmpImage(
RasterImage^ rasterImage,
unsigned short bitsPerPixel,
BitmapCompression compression,
double horizontalResolution,
double verticalResolution
)
new :
rasterImage : RasterImage *
bitsPerPixel : uint16 *
compression : BitmapCompression *
horizontalResolution : float *
verticalResolution : float -> BmpImage
Parameters
- rasterImage
- Type: Aspose.ImagingRasterImage
The image to 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.
ExceptionsException | Condition |
---|
ArgumentNullException | The raster image cannot be null;rasterImage |
BmpImageException | The height should be positive. |
ArgumentException | Palette should be specified for images with 8 bits per pixel or less.;palette |
ExamplesThe example shows how to load a BmpImage from another instance of RasterImage with the specified bit depth and compression.
[C#]
string dir = "c:\\temp\\";
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))
{
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);
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))
{
bmpImage.Save(dir + "output.24bpp.96dpi.bmp");
}
}
See Also