Bitmapclass
Constructors1
Showing 1 constructors
public Bitmap(int width, int height, bool floatingPoint = False)
| Parameter | Type | Description |
|---|---|---|
| width | int | — |
| height | int | — |
| floatingPoint = False | bool | — |
No results match this filter.
Methods59
Showing 59 methods
public void Adjust(float brightness = 1, float contrast = 1, float saturation = 1, float hueDegrees = 0)
Adjusts brightness, contrast, and saturation in one pass.
| Parameter | Type | Description |
|---|---|---|
| brightness = 1 | float | — |
| contrast = 1 | float | — |
| saturation = 1 | float | — |
| hueDegrees = 0 | float | — |
void—public void AdjustHue(float angle)
Adjusts the hue of the bitmap.
| Parameter | Type | Description |
|---|---|---|
| angle | float | The angle to rotate the hue, in degrees (0 to 360). |
void—public void Blur(float radius, bool tileClamp = True)
Applies a Gaussian blur effect to the current bitmap.
| Parameter | Type | Description |
|---|---|---|
| radius | float | The radius of the blur, controlling its intensity. Must be non-negative. |
| tileClamp = True | bool | Determines the behavior at the edges of the bitmap: `true` to clamp the edges (default), or `false` to repeat the edges. |
void—public void Clear(Color color)
Clears the bitmap to the specified color.
| Parameter | Type | Description |
|---|---|---|
| color | Color | The color to fill the bitmap with. |
void—public void Colorize(Color color)
Color the bitmap using this color, respect alpha
| Parameter | Type | Description |
|---|---|---|
| color | Color | — |
void—public static Sandbox.Bitmap CreateFromBytes(byte[] data)
Loads a bitmap from the specified byte array.
| Parameter | Type | Description |
|---|---|---|
| data | byte[] | The byte array containing the image data. |
public static Sandbox.Bitmap CreateFromIesBytes(byte[] data)
| Parameter | Type | Description |
|---|---|---|
| data | byte[] | — |
public static Sandbox.Bitmap CreateFromPsdBytes(byte[] data)
Creates a Bitmap instance from PSD file data.
| Parameter | Type | Description |
|---|---|---|
| data | byte[] | Byte array containing the PSD file data. |
public static Sandbox.Bitmap CreateFromSvgString(string svgContents, System.Nullable`1<int> width, System.Nullable`1<int> height, System.Nullable`1<Vector2> scale = null, System.Nullable`1<Vector2> offset = null, System.Nullable`1<float> rotation = null)
| Parameter | Type | Description |
|---|---|---|
| svgContents | string | — |
| width | Nullable<int> | — |
| height | Nullable<int> | — |
| scale = null | Nullable<Vector2> | — |
| offset = null | Nullable<Vector2> | — |
| rotation = null | Nullable<float> | — |
public static Sandbox.Bitmap CreateFromTgaBytes(byte[] data)
| Parameter | Type | Description |
|---|---|---|
| data | byte[] | — |
public static Sandbox.Bitmap CreateFromTifBytes(byte[] data)
| Parameter | Type | Description |
|---|---|---|
| data | byte[] | — |
public Sandbox.Bitmap Crop(Sandbox.Rect rect)
Crops the bitmap to the specified rectangle.
| Parameter | Type | Description |
|---|---|---|
| rect | Rect | The rectangle to crop to. |
public virtual sealed void Dispose()
void—public void DrawBitmap(Sandbox.Bitmap bitmap, Sandbox.Rect destRect)
Draws another bitmap onto this bitmap.
| Parameter | Type | Description |
|---|---|---|
| bitmap | Bitmap | The bitmap to draw. |
| destRect | Rect | The destination rectangle for the drawn bitmap. |
void—public void DrawLine(Vector2 start, Vector2 end)
Draws a line using the current pen settings.
| Parameter | Type | Description |
|---|---|---|
| start | Vector2 | The starting point of the line. |
| end | Vector2 | The ending point of the line. |
void—public void DrawLines(Vector2[] points)
Draws connected lines through a series of points using the current pen settings.
| Parameter | Type | Description |
|---|---|---|
| points | Vector2[] | The points to connect with lines. |
void—public void DrawPolygon(Vector2[] points)
Draws a polygon using the current pen settings.
| Parameter | Type | Description |
|---|---|---|
| points | Vector2[] | The points of the polygon. |
void—public void DrawRoundRect(Sandbox.Rect rect, Sandbox.UI.Margin margins)
Draws a rectangle using the current pen settings.
| Parameter | Type | Description |
|---|---|---|
| rect | Rect | — |
| margins | Margin | — |
void—public void DrawText(Sandbox.TextRendering.Scope scope, Sandbox.Rect rect, Sandbox.TextFlag flags = 132)
Draws text onto this bitmap
| Parameter | Type | Description |
|---|---|---|
| scope | Scope | — |
| rect | Rect | — |
| flags = 132 | TextFlag | — |
void—public Sandbox.Bitmap FlipHorizontal()
Flips the bitmap horizontally.
public Sandbox.Bitmap FlipVertical()
Flips the bitmap vertically.
public Color GetPixel(int x, int y)
Retrieves the color of a specific pixel in the bitmap.
| Parameter | Type | Description |
|---|---|---|
| x | int | The x-coordinate of the pixel. |
| y | int | The y-coordinate of the pixel. |
public Color[] GetPixels()
Retrieves the pixel data of the bitmap as an array of colors.
public Color32[] GetPixels32()
Retrieves the pixel data of the bitmap as an array of colors.
public Sandbox.Bitmap HeightmapToNormalMap(float strength = 1)
Converts a heightmap to a normal map using parallel processing.
| Parameter | Type | Description |
|---|---|---|
| strength = 1 | float | The strength of the normal map effect (default is 1.0). |
public void InsertPadding(Sandbox.UI.Margin margin)
Shrink the image by adding padding all around - without resizing the bitmap
| Parameter | Type | Description |
|---|---|---|
| margin | Margin | — |
void—public void InvertColor()
Inverts the colors of the bitmap while preserving alpha.
void—public static bool IsIes(byte[] data)
Return true if this data is a Ies file
| Parameter | Type | Description |
|---|---|---|
| data | byte[] | — |
bool—public bool IsOpaque()
Returns true if this bitmap is completely opaque (no alpha) This does a pixel by pixel search, so it's not the fastest.
bool—public static bool IsPsd(byte[] data)
Checks if the provided byte array is a valid PSD file.
| Parameter | Type | Description |
|---|---|---|
| data | byte[] | Byte array to check. |
boolTrue if the data is a PSD file, otherwise false.public static bool IsTga(byte[] data)
Return true if this data is a Tga file
| Parameter | Type | Description |
|---|---|---|
| data | byte[] | — |
bool—public static bool IsTif(System.ReadOnlySpan`1<byte> data)
| Parameter | Type | Description |
|---|---|---|
| data | ReadOnlySpan<byte> | — |
bool—public Sandbox.Bitmap Resize(int newWidth, int newHeight, bool smooth = True)
Resizes the bitmap to the specified dimensions and returns a new bitmap.
| Parameter | Type | Description |
|---|---|---|
| newWidth | int | The new width of the bitmap. |
| newHeight | int | The new height of the bitmap. |
| smooth = True | bool | Resample smoothly. If false this will be nearest neighbour. |
public Sandbox.Bitmap Rotate(float degrees)
Rotates the bitmap by the specified angle.
| Parameter | Type | Description |
|---|---|---|
| degrees | float | The angle in degrees to rotate the bitmap. |
public void SetAntialias(bool on)
Sets the pen for drawing with a solid color and stroke style.
| Parameter | Type | Description |
|---|---|---|
| on | bool | — |
void—public void SetBlendMode(Sandbox.BlendMode blendMode)
Sets the pen to use a specific blend mode.
| Parameter | Type | Description |
|---|---|---|
| blendMode | BlendMode | The blend mode to apply. |
void—public void SetDashedPen(Color color, float width, float[] dashPattern)
Sets the pen for drawing dashed or dotted lines.
| Parameter | Type | Description |
|---|---|---|
| color | Color | The color of the pen. |
| width | float | The width of the pen in pixels. |
| dashPattern | float[] | An array defining the dash pattern (e.g., [10, 5] for 10px dash, 5px gap). |
void—public void SetFill(Color color)
Sets the pen for drawing filled shapes with a solid color.
| Parameter | Type | Description |
|---|---|---|
| color | Color | The color to fill the shapes with. |
void—public void SetLinearGradient(Vector2 start, Vector2 end, Sandbox.Gradient gradient)
Sets the pen for drawing with a linear gradient.
| Parameter | Type | Description |
|---|---|---|
| start | Vector2 | the gradient's start point. |
| end | Vector2 | the gradient's end point. |
| gradient | Gradient | The color of the gradient. |
void—public void SetPen(Color color, float width)
Sets the pen for drawing with a solid color and stroke style.
| Parameter | Type | Description |
|---|---|---|
| color | Color | The color of the pen. |
| width | float | The width of the pen in pixels. |
void—public void SetPixel(int x, int y, Color color)
Sets the color of a specific pixel in the bitmap.
| Parameter | Type | Description |
|---|---|---|
| x | int | The x-coordinate of the pixel. |
| y | int | The y-coordinate of the pixel. |
| color | Color | The color to set the pixel to. |
void—public void SetRadialGradient(Vector2 center, float radius, Sandbox.Gradient gradient)
Sets the pen for drawing with a radial gradient.
| Parameter | Type | Description |
|---|---|---|
| center | Vector2 | The gradient's center. |
| radius | float | The radius of the gradient. |
| gradient | Gradient | The color of the gradient. |
void—public void Sharpen(float amount, bool tileClamp = True)
Applies a Gaussian blur effect to the current bitmap.
| Parameter | Type | Description |
|---|---|---|
| amount | float | — |
| tileClamp = True | bool | — |
void—public void Tint(Color color)
Tint the bitmap using this color, respect alpha
| Parameter | Type | Description |
|---|---|---|
| color | Color | — |
void—public byte[] ToBmp()
Exports the bitmap as a BMP byte array.
byte[]A byte array containing the BMP image data.public byte[] ToFormat(Sandbox.ImageFormat format)
Exports the bitmap to the specified engine format
| Parameter | Type | Description |
|---|---|---|
| format | ImageFormat | The target image format to encode to. |
byte[]—public byte[] ToJpg(int quality = 100)
Exports the bitmap as a JPEG byte array with the specified quality.
| Parameter | Type | Description |
|---|---|---|
| quality = 100 | int | The quality of the JPEG, between 0 and 100. |
byte[]A byte array containing the JPEG image data.public byte[] ToPng()
Exports the bitmap as a PNG byte array.
byte[]A byte array containing the PNG image data.public Sandbox.Texture ToTexture(bool mips = True)
Try to create a texture from this bitmap
| Parameter | Type | Description |
|---|---|---|
| mips = True | bool | — |
public byte[] ToWebP(int quality = 100)
Exports the bitmap as an HDR WebP byte array with the specified quality.
| Parameter | Type | Description |
|---|---|---|
| quality = 100 | int | The quality of the WebP image, between 0 and 100. |
byte[]A byte array containing the WebP HDR image data.No results match this filter.
Properties9
Showing 9 properties
public int Sandbox.Bitmap.ByteCount { get; set; }
int—public int Sandbox.Bitmap.BytesPerPixel { get; set; }
int—public int Sandbox.Bitmap.Height { get; set; }
int—public bool Sandbox.Bitmap.IsFloatingPoint { get; set; }
bool—public virtual sealed bool Sandbox.Bitmap.IsValid { get; set; }
bool—public Vector2Int Sandbox.Bitmap.Size { get; set; }
The width and height of the bitmap
public int Sandbox.Bitmap.Width { get; set; }
int—No results match this filter.