Table of Contents

Class BmpImage

Namespace
Aspose.Imaging.FileFormats.Bmp
Assembly
Aspose.Imaging.dll

You can effortlessly handle Bitmap (BMP) and Device Independent Bitmap (DIB) files, facilitating efficient manipulation and processing of raster images. Performing various operations on images, this API streamlines the workflow, offering developers a reliable toolkit for working with BMP and DIB formats in their software applications.

public sealed class BmpImage : RasterCachedImage, IDisposable, IObjectWithBounds, IRasterImageArgb32PixelLoader, IRasterImageRawDataLoader, IHasXmpData, IHasMetadata
Inheritance
BmpImage
Implements
Inherited Members

Constructors

BmpImage(RasterImage)

Effortlessly create a new instance of the BmpImage class by initializing it with a RasterImage object. Perfect for developers looking to seamlessly convert existing raster images to the BmpImage format, ensuring compatibility and ease of integration into their projects.

public BmpImage(RasterImage rasterImage)

Parameters

rasterImage RasterImage

The image to initialize pixel and palette data with.

Exceptions

ArgumentNullException

The raster image is null.

BmpImageException

The height must be positive.

ArgumentException

Palette must be specified for images with 8 bits per pixel or less.

BmpImage(RasterImage, ushort, BitmapCompression, double, double)

Start working with the BmpImage class seamlessly by creating a new instance using a rasterImage along with specified parameters like bitsPerPixel and compression. Perfect for developers seeking a straightforward way to handle BmpImage objects, ensuring flexibility and efficiency in their projects.

public BmpImage(RasterImage rasterImage, ushort bitsPerPixel, BitmapCompression compression, double horizontalResolution, double verticalResolution)

Parameters

rasterImage RasterImage

The image to initialize pixel and palette data with.

bitsPerPixel ushort

The bits per pixel.

compression BitmapCompression

The compression to use.

horizontalResolution double

The horizontal resolution. Note due to the rounding the resulting resolution may slightly differ from the passed.

verticalResolution double

The vertical resolution. Note due to the rounding the resulting resolution may slightly differ from the passed.

Exceptions

ArgumentNullException

The raster image is null.

BmpImageException

The height must be positive.

ArgumentException

Palette must be specified for images with 8 bits per pixel or less.

BmpImage(Stream)

Begin using the BmpImage class effortlessly by initializing a new instance with this constructor, using a stream as input. Perfect for developers seeking a convenient way to work with BmpImage objects from various data sources, ensuring flexibility and ease of integration.

public BmpImage(Stream stream)

Parameters

stream Stream

The stream to load image from and initialize pixel and palette data with.

Exceptions

ArgumentNullException

The raster image is null.

BmpImageException

The height must be positive.

ArgumentException

Palette must be specified for images with 8 bits per pixel or less.

BmpImage(Stream, ushort, BitmapCompression, double, double)

Start working with the BmpImage class seamlessly by creating a new instance using a stream, along with specified parameters like bitsPerPixel and compression. Perfect for developers seeking a straightforward way to handle BmpImage objects, ensuring flexibility and efficiency in their projects.

public BmpImage(Stream stream, ushort bitsPerPixel, BitmapCompression compression, double horizontalResolution, double verticalResolution)

Parameters

stream Stream

The stream to load image from and initialize pixel and palette data with.

bitsPerPixel ushort

The bits per pixel.

compression BitmapCompression

The compression to use.

horizontalResolution double

The horizontal resolution. Note due to the rounding the resulting resolution may slightly differ from the passed.

verticalResolution double

The vertical resolution. Note due to the rounding the resulting resolution may slightly differ from the passed.

Exceptions

ArgumentNullException

The raster image is null.

BmpImageException

The height must be positive.

ArgumentException

Palette must be specified for images with 8 bits per pixel or less.

BmpImage(int, int)

Start using the BmpImage class effortlessly by creating a new instance with specified width and height parameters. Ideal for developers seeking a convenient way to generate BmpImage objects of custom dimensions, ensuring flexibility and ease of integration into their projects.

public BmpImage(int width, int height)

Parameters

width int

The image width.

height int

The image height.

Exceptions

BmpImageException

The height must be positive.

ArgumentException

Palette must be specified for images with 8 bits per pixel or less.

BmpImage(int, int, ushort, IColorPalette)

Begin using the BmpImage class seamlessly by initializing a new instance with parameters such as width, height, bit depth, and palette. Perfect for developers seeking a straightforward way to create BmpImage objects with custom dimensions and color configurations, ensuring flexibility and efficiency in their projects.

public BmpImage(int width, int height, ushort bitsPerPixel, IColorPalette palette)

Parameters

width int

The image width.

height int

The image height.

bitsPerPixel ushort

The bits per pixel.

palette IColorPalette

The color palette.

Exceptions

BmpImageException

The height must be positive.

ArgumentException

Palette must be specified for images with 8 bits per pixel or less.

BmpImage(int, int, ushort, IColorPalette, BitmapCompression, double, double)

Effortlessly create a new instance of the BmpImage class with this constructor, specifying parameters like width, height, bitsPerPixel, and palette. Perfect for developers seeking a convenient way to generate BmpImage objects with custom dimensions and color configurations, ensuring flexibility and ease of integration into their projects.

public BmpImage(int width, int height, ushort bitsPerPixel, IColorPalette palette, BitmapCompression compression, double horizontalResolution, double verticalResolution)

Parameters

width int

The image width.

height int

The image height.

bitsPerPixel ushort

The bits per pixel.

palette IColorPalette

The color palette.

compression BitmapCompression

The compression to use.

horizontalResolution double

The horizontal resolution. Note due to the rounding the resulting resolution may slightly differ from the passed.

verticalResolution double

The vertical resolution. Note due to the rounding the resulting resolution may slightly differ from the passed.

Exceptions

BmpImageException

The height must be positive.

ArgumentException

Palette must be specified for images with 8 bits per pixel or less.

BmpImage(string)

Start using the BmpImage class effortlessly with this constructor that initializes a new instance. Perfect for developers who want to get up and running with BmpImage objects quickly and efficiently.

public BmpImage(string path)

Parameters

path string

The path to load image from and initialize pixel and palette data with.

Exceptions

ArgumentNullException

The raster image is null.

BmpImageException

The height must be positive.

ArgumentException

Palette must be specified for images with 8 bits per pixel or less.

BmpImage(string, ushort, BitmapCompression, double, double)

Effortlessly create a new instance of the BmpImage class with this constructor, using specified parameters like path, bitsPerPixel, and compression. Ideal for developers looking to initialize BmpImage objects quickly and efficiently, with precise control over image characteristics.

public BmpImage(string path, ushort bitsPerPixel, BitmapCompression compression, double horizontalResolution, double verticalResolution)

Parameters

path string

The path to load image from and initialize pixel and palette data with.

bitsPerPixel ushort

The bits per pixel.

compression BitmapCompression

The compression to use.

horizontalResolution double

The horizontal resolution. Note due to the rounding the resulting resolution may slightly differ from the passed.

verticalResolution double

The vertical resolution. Note due to the rounding the resulting resolution may slightly differ from the passed.

Exceptions

ArgumentNullException

The raster image is null.

BmpImageException

The height must be positive.

ArgumentException

Palette must be specified for images with 8 bits per pixel or less.

Properties

BitmapInfoHeader

Quickly access essential details about your bitmap image with this straightforward function. Perfect for developers needing to retrieve header information for their images.

public BitmapInfoHeader BitmapInfoHeader { get; }

Property Value

BitmapInfoHeader

The bitmap information header.

BitsPerPixel

Access the number of bits per pixel for the image with ease using this property. Perfect for developers seeking quick information about image quality and depth.

public override int BitsPerPixel { get; }

Property Value

int

The image bits per pixel count.

Compression

Retrieve the compression type used for the image effortlessly with this property. Perfect for developers needing to quickly access information about image compression.

public BitmapCompression Compression { get; }

Property Value

BitmapCompression

The image compression.

FileFormat

Easily retrieve the file format value with this user-friendly property. Ideal for developers seeking quick access to information about the file format.

public override FileFormat FileFormat { get; }

Property Value

FileFormat

Height

Retrieve the height of the image effortlessly with this property. Ideal for developers needing quick access to information about image dimensions.

public override int Height { get; }

Property Value

int

The image height.

HorizontalResolution

This property allows you to easily get or set the horizontal resolution, measured in pixels per inch, of the RasterImage object. Ideal for developers needing precise control over image resolution for their applications.

public override double HorizontalResolution { get; set; }

Property Value

double

The horizontal resolution.

Remarks

Note by default this value is always 96 since different platforms cannot return the screen resolution. You may consider using the SetResolution method for updating both resolution values in single call.

RawDataFormat

Easily obtain the format of your raw data with this user-friendly function. Perfect for developers looking to quickly access crucial information about their data format.

public override PixelDataFormat RawDataFormat { get; }

Property Value

PixelDataFormat

The raw data format.

RawLineSize

Quickly access the size of each raw line in bytes with this straightforward property. Ideal for developers needing to efficiently handle raw image data.

public override int RawLineSize { get; }

Property Value

int

The raw line size in bytes.

VerticalResolution

Easily retrieve or set the vertical resolution, measured in pixels per inch, of this RasterImage object with this property. Perfect for developers requiring precise control over image resolution in their applications.

public override double VerticalResolution { get; set; }

Property Value

double

The vertical resolution.

Remarks

Note by default this value is always 96 since different platforms cannot return the screen resolution. You may consider using the SetResolution method for updating both resolution values in single call.

Width

Access the width of the image easily with this property. Ideal for developers seeking quick information about the image dimensions.

public override int Width { get; }

Property Value

int

The image width.

Methods

GetDefaultOptions(object[])

Retrieve the default options effortlessly with this straightforward method. Ideal for developers seeking quick access to default image settings or configurations.

public override ImageOptionsBase GetDefaultOptions(object[] args)

Parameters

args object[]

The arguments.

Returns

ImageOptionsBase

Default options

OnCached()

Called when data is cached and all related resources may be de-allocated.

protected override void OnCached()

OnPaletteChanging(IColorPalette, IColorPalette)

protected override void OnPaletteChanging(IColorPalette oldPalette, IColorPalette newPalette)

Parameters

oldPalette IColorPalette
newPalette IColorPalette

SaveData(Stream)

protected override void SaveData(Stream stream)

Parameters

stream Stream

SetResolution(double, double)

Adjust the resolution of your RasterImage effortlessly with this user-friendly method. Perfect for developers seeking precise control over image resolution in their applications.

public override void SetResolution(double dpiX, double dpiY)

Parameters

dpiX double

The horizontal resolution, in dots per inch, of the RasterImage.

dpiY double

The vertical resolution, in dots per inch, of the RasterImage.

ToBitmap()

Easily convert your raster image to a bitmap with this simple method. Perfect for developers needing to seamlessly transition between different image formats.

public override Bitmap ToBitmap()

Returns

Bitmap

The bitmap

UpdateDimensions(int, int)

protected override void UpdateDimensions(int newWidth, int newHeight)

Parameters

newWidth int
newHeight int