Table of Contents

Class Bitmap

Namespace
Lime
Assembly
Lime.dll

Wraps native bitmap and exposes unified methods to work with images.

public class Bitmap : IDisposable
Inheritance
Bitmap
Implements
Inherited Members

Constructors

Bitmap(Color4[], int, int)

Initializes a new instance of Bitmap class with the specified array of pixels, width and height.

public Bitmap(Color4[] data, int width, int height)

Parameters

data Color4[]

The array of pixels of Color4 type.

width int

The width, in pixels, of the new bitmap.

height int

The height, in pixels, of the new bitmap.

Bitmap(Stream)

Initializes a new instance of Bitmap class from the specified data stream.

public Bitmap(Stream stream)

Parameters

stream Stream

The data stream used to load the image.

Properties

HasAlpha

Gets a value indicating whether this bitmap has at least one non-opaque pixel.

public bool HasAlpha { get; }

Property Value

bool

Height

Gets the height, in pixels, of this bitmap.

public int Height { get; }

Property Value

int

IsValid

Gets a value indicating whether this bitmap is valid.

public bool IsValid { get; }

Property Value

bool

true if this bitmap is not null or empty; otherwise, false.

NativeBitmap

Gets a platform specific bitmap.

public Bitmap NativeBitmap { get; }

Property Value

Bitmap

Size

Gets the size this bitmap.

public Vector2 Size { get; }

Property Value

Vector2

Width

Gets the width, in pixels, of this bitmap.

public int Width { get; }

Property Value

int

Methods

Clone()

Creates an exact copy of this bitmap.

public Bitmap Clone()

Returns

Bitmap

The new bitmap that this method creates.

Crop(IntRectangle)

Creates a copy of the section of this bitmap defined by IntRectangle structure.

public Bitmap Crop(IntRectangle cropArea)

Parameters

cropArea IntRectangle

Defines the portion of this bitmap to copy.

Returns

Bitmap

The new bitmap that this method creates.

Remarks

This method can not create empty bitmap. Section should be inside of the bitmap.

Dispose()

Releases all resources used by this bitmap.

public void Dispose()

GetPixels()

Gets the array of pixels from this bitmap.

public Color4[] GetPixels()

Returns

Color4[]

An Color4 array of pixels.

Rescale(int, int)

Creates a copy of this bitmap scaled to the specified size.

public Bitmap Rescale(int newWidth, int newHeight)

Parameters

newWidth int

The width, in pixels, of the new bitmap.

newHeight int

The height, in pixels, of the new bitmap.

Returns

Bitmap

The new bitmap that this method creates.

Remarks

This method can not create empty bitmap or flip it.

SaveTo(Stream, CompressionFormat)

Saves this image to the specified stream in specified compression format (default compression is PNG).

public void SaveTo(Stream stream, CompressionFormat compression = CompressionFormat.Png)

Parameters

stream Stream

The stream where the image will be saved.

compression CompressionFormat

Jpeg or Png.

SaveTo(string, CompressionFormat)

Saves this image to file with specified path in specified compression format (default compression is PNG).

public void SaveTo(string path, CompressionFormat compression = CompressionFormat.Png)

Parameters

path string

The path to a file.

compression CompressionFormat

Jpeg or Png.