Api Sandbox Bitmap
class

Bitmap

public sealed class Bitmap

Constructors

Bitmap(Int32 width, Int32 height, Boolean floatingPoint)

Properties

Name Type Description
Width Int32
Height Int32
BytesPerPixel Int32
ByteCount Int32
Rect Rect
Size Vector2Int The width and height of the bitmap
Center Vector2
IsFloatingPoint Boolean
IsValid virtual Boolean

Methods

virtual Void Dispose()
Void Clear(Color color)

Clears the bitmap to the specified color.

color — The color to fill the bitmap with.
Color[] GetPixels()

Retrieves the pixel data of the bitmap as an array of colors.

Rgba16[] GetPixels16()

Retrieves the pixel data of the bitmap as an array of colors.

Color32[] GetPixels32()

Retrieves the pixel data of the bitmap as an array of colors.

Void SetPixels(Color[] colors)
Color GetPixel(Int32 x, Int32 y)

Retrieves the color of a specific pixel in the bitmap.

x — The x-coordinate of the pixel.
y — The y-coordinate of the pixel.
returns — The color of the pixel at the specified coordinates.
Void SetPixel(Int32 x, Int32 y, Color color)

Sets the color of a specific pixel in the bitmap.

x — The x-coordinate of the pixel.
y — The y-coordinate of the pixel.
color — The color to set the pixel to.
Bitmap Clone()

Copy the bitmap to a new one without any changes.

Boolean IsOpaque()

Returns true if this bitmap is completely opaque (no alpha) This does a pixel by pixel search, so it's not the fastest.

Void DrawRect(Rect rect)

Draws a rectangle using the current pen settings.

rect — The rectangle to draw.
Void DrawRect(Single x, Single y, Single width, Single height)

Draws a rectangle using the current pen settings.

x — The x-coordinate of the top-left corner.
y — The y-coordinate of the top-left corner.
width — The width of the rectangle.
height — The height of the rectangle.
Void DrawRoundRect(Rect rect, Margin margins)

Draws a rectangle using the current pen settings.

Void DrawCircle(Vector2 center, Single radius)

Draws a circle using the current pen settings.

center — The center of the circle.
radius — The radius of the circle.
Void DrawCircle(Single x, Single y, Single radius)

Draws a circle using the current pen settings.

x — The x-coordinate of the circle's center.
y — The y-coordinate of the circle's center.
radius — The radius of the circle.
Void DrawPolygon(Vector2[] points)

Draws a polygon using the current pen settings.

points — The points of the polygon.
Void DrawArc(Rect rect, Single startAngle, Single sweepAngle)

Draws an arc using the current pen settings.

rect — The bounding rectangle of the arc.
startAngle — The starting angle of the arc, in degrees.
sweepAngle — The sweep angle of the arc, in degrees.
Void DrawArc(Rect rect, Single startAngle, Single sweepAngle, Boolean useCenter)

Draws an arc using the current pen settings, with an option to connect to the center.

rect — The bounding rectangle of the arc.
startAngle — The starting angle of the arc, in degrees.
sweepAngle — The sweep angle of the arc, in degrees.
useCenter — If true, connects the arc endpoints to the center point, forming a pie shape.
Void DrawBitmap(Bitmap bitmap, Rect destRect)

Draws another bitmap onto this bitmap.

bitmap — The bitmap to draw.
destRect — The destination rectangle for the drawn bitmap.
Void DrawLine(Vector2 start, Vector2 end)

Draws a line using the current pen settings.

start — The starting point of the line.
end — The ending point of the line.
Void DrawLines(Vector2[] points)

Draws connected lines through a series of points using the current pen settings.

points — The points to connect with lines.
Void Blur(Single radius, Boolean tileClamp = True)

Applies a Gaussian blur effect to the current bitmap.

radius — The radius of the blur, controlling its intensity. Must be non-negative.
tileClamp — Determines the behavior at the edges of the bitmap: true to clamp the edges (default), or false to repeat the edges.
Void Sharpen(Single amount, Boolean tileClamp = True)

Applies a Gaussian blur effect to the current bitmap.

Void Adjust(Single brightness = 1, Single contrast = 1, Single saturation = 1, Single hueDegrees = 0)

Adjusts brightness, contrast, and saturation in one pass.

Void AdjustHue(Single angle)

Adjusts the hue of the bitmap.

angle — The angle to rotate the hue, in degrees (0 to 360).
Void Colorize(Color color)

Color the bitmap using this color, respect alpha

Void Tint(Color color)

Tint the bitmap using this color, respect alpha

color
Void InsertPadding(Margin margin)

Shrink the image by adding padding all around - without resizing the bitmap

Bitmap HeightmapToNormalMap(Single strength = 1)

Converts a heightmap to a normal map using parallel processing.

strength — The strength of the normal map effect (default is 1.0).
returns — The generated normal map as an SKBitmap.
Void InvertColor()

Inverts the colors of the bitmap while preserving alpha.

static Bitmap CreateFromBytes(Byte[] data)

Loads a bitmap from the specified byte array.

data — The byte array containing the image data.
returns — A new Bitmap instance.
static Bitmap CreateFromIesBytes(Byte[] data)
static Boolean IsIes(Byte[] data)

Return true if this data is a Ies file

static Bitmap CreateFromPsdBytes(Byte[] data)

Creates a Bitmap instance from PSD file data.

data — Byte array containing the PSD file data.
returns — A Bitmap instance if successful, or null if the data is not valid PSD.
static Boolean IsPsd(Byte[] data)

Checks if the provided byte array is a valid PSD file.

data — Byte array to check.
returns — True if the data is a PSD file, otherwise false.
static Bitmap CreateFromSvgString(String svgContents, Int32? width, Int32? height, Vector2? scale = null, Vector2? offset = null, Single? rotation = null)
static Bitmap CreateFromTgaBytes(Byte[] data)
static Boolean IsTga(Byte[] data)

Return true if this data is a Tga file

static Bitmap CreateFromTifBytes(Byte[] data)
static Boolean IsTif(ReadOnlySpan<Byte> data)
Void SetAntialias(Boolean on)

Sets the pen for drawing with a solid color and stroke style.

Void SetBlendMode(BlendMode blendMode)

Sets the pen to use a specific blend mode.

blendMode — The blend mode to apply.
Void SetPen(Color color, Single width)

Sets the pen for drawing with a solid color and stroke style.

color — The color of the pen.
width — The width of the pen in pixels.
Void SetDashedPen(Color color, Single width, Single[] dashPattern)

Sets the pen for drawing dashed or dotted lines.

color — The color of the pen.
width — The width of the pen in pixels.
dashPattern — An array defining the dash pattern (e.g., [10, 5] for 10px dash, 5px gap).
Void SetFill(Color color)

Sets the pen for drawing filled shapes with a solid color.

color — The color to fill the shapes with.
Void SetLinearGradient(Vector2 start, Vector2 end, Gradient gradient)

Sets the pen for drawing with a linear gradient.

start — the gradient's start point.
end — the gradient's end point.
gradient — The color of the gradient.
Void SetRadialGradient(Vector2 center, Single radius, Gradient gradient)

Sets the pen for drawing with a radial gradient.

center — The gradient's center.
radius — The radius of the gradient.
gradient — The color of the gradient.
Byte[] ToJpg(Int32 quality = 100)

Exports the bitmap as a JPEG byte array with the specified quality.

quality — The quality of the JPEG, between 0 and 100.
returns — A byte array containing the JPEG image data.
Byte[] ToPng()

Exports the bitmap as a PNG byte array.

returns — A byte array containing the PNG image data.
Byte[] ToBmp()

Exports the bitmap as a BMP byte array.

returns — A byte array containing the BMP image data.
Byte[] ToWebP(Int32 quality = 100)

Exports the bitmap as an HDR WebP byte array with the specified quality.

quality — The quality of the WebP image, between 0 and 100.
returns — A byte array containing the WebP HDR image data.
Byte[] ToFormat(ImageFormat format)

Exports the bitmap to the specified engine format

Void DrawText(Scope scope, Rect rect, TextFlag flags = 132)

Draws text onto this bitmap

Texture ToTexture(Boolean mips = True)

Try to create a texture from this bitmap

Bitmap Rotate(Single degrees)

Rotates the bitmap by the specified angle.

degrees — The angle in degrees to rotate the bitmap.
returns — A new Bitmap instance with the rotated image.
Bitmap Resize(Int32 newWidth, Int32 newHeight, Boolean smooth = True)

Resizes the bitmap to the specified dimensions and returns a new bitmap.

newWidth — The new width of the bitmap.
newHeight — The new height of the bitmap.
smooth — Resample smoothly. If false this will be nearest neighbour.
returns — A new Bitmap instance with the specified dimensions.
Bitmap FlipVertical()

Flips the bitmap vertically.

returns — A new Bitmap instance with the flipped image.
Bitmap FlipHorizontal()

Flips the bitmap horizontally.

returns — A new Bitmap instance with the flipped image.
Bitmap Crop(Rect rect)

Crops the bitmap to the specified rectangle.

rect — The rectangle to crop to.
returns — A new Bitmap instance with the cropped image.
Assembly: Sandbox.Engine Namespace: Sandbox Full Name: Sandbox.Bitmap