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
intThe width, in pixels, of the new bitmap.
height
intThe 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
StreamThe 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
Height
Gets the height, in pixels, of this bitmap.
public int Height { get; }
Property Value
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
Size
Gets the size this bitmap.
public Vector2 Size { get; }
Property Value
Width
Gets the width, in pixels, of this bitmap.
public int Width { get; }
Property Value
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
IntRectangleDefines 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
Rescale(int, int)
Creates a copy of this bitmap scaled to the specified size.
public Bitmap Rescale(int newWidth, int newHeight)
Parameters
newWidth
intThe width, in pixels, of the new bitmap.
newHeight
intThe 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
StreamThe stream where the image will be saved.
compression
CompressionFormatJpeg 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
stringThe path to a file.
compression
CompressionFormatJpeg or Png.