Pixmapclass

A pixel map, or just a simple image.

objectPixmap
Namespace
Editor
Assembly
Sandbox.Tools
Declaration
public class Editor.Pixmap

Constructors2

Showing 2 constructors

Methods18

Showing 18 methods

public void Clear(Color color)PUBLIC

Fill the pixel map with given color.

ParameterTypeDescription
colorColor
Returns:void

protected virtual override void Finalize()PROTECTEDVIRTUALOVERRIDE

Returns:void

public static Editor.Pixmap FromBitmap(Sandbox.Bitmap bitmap)PUBLICSTATIC

Create a pixmap from a bitmap

ParameterTypeDescription
bitmapBitmap
Returns:Pixmap

public static Editor.Pixmap FromFile(string filename)PUBLICSTATIC

Load an image from a file on disk, specifically from "core/tools/images".

ParameterTypeDescription
filenamestring
Returns:Pixmap

public static Editor.Pixmap FromTexture(Sandbox.Texture texture, bool withAlpha = True)PUBLICSTATIC

Create a pixmap from a texture.

ParameterTypeDescription
textureTexture
withAlpha = Truebool
Returns:Pixmap

public byte[] GetBmp(int quality)PUBLIC

Returns the raw bytes of a BMP file that contains this pixel maps image. Internally writes and deletes a file, so be careful using it often.

ParameterTypeDescription
qualityint
Returns:byte[]

public byte[] GetJpeg(int quality)PUBLIC

Returns the raw bytes of a JPEG file that contains this pixel maps image. Internally writes and deletes a file, so be careful using it often.

ParameterTypeDescription
qualityintJPEG quality, 0 to 100.
Returns:byte[]

public Color GetPixel(int x, int y)PUBLIC

ParameterTypeDescription
xint
yint
Returns:Color

public byte[] GetPng()PUBLIC

Returns the raw bytes of a PNG file that contains this pixel maps image. Internally writes and deletes a file, so be careful using it often.

Returns:byte[]

public bool SaveJpg(string filename, int quality = 70)PUBLIC

Save the pixel map as a JPEG file at given location.

ParameterTypeDescription
filenamestringA full, valid absolute target path. Will not create directories on its own.
quality = 70intJPEG quality, 0 to 100.
Returns:boolWhether the file was created or not.

public bool SavePng(string filename)PUBLIC

Save the pixel map as a PNG file at given location.

ParameterTypeDescription
filenamestringA full, valid absolute target path. Will not create directories on its own.
Returns:boolWhether the file was created or not.

Properties4

Showing 4 properties

public bool Editor.Pixmap.HasAlpha { get; set; }PUBLICGETSET

Whether this pixel map supports the alpha channel.

Returns:bool

public int Editor.Pixmap.Height { get; set; }PUBLICGETSET

Height of the pixel map.

Returns:int

public Vector2 Editor.Pixmap.Size { get; set; }PUBLICGETSET

THe size of this pixel map.

Returns:Vector2

public int Editor.Pixmap.Width { get; set; }PUBLICGETSET

Width of the pixel map.

Returns:int

On this page

Constructorspublic Pixmap(System.Int32 width, System.Int32 height)public Pixmap(Vector2 size)Methodspublic System.Void Clear(Color color)protected virtual override System.Void Finalize()public static Editor.Pixmap FromBitmap(Sandbox.Bitmap bitmap)public static Editor.Pixmap FromFile(System.String filename)public static Editor.Pixmap FromTexture(Sandbox.Texture texture, System.Boolean withAlpha = True)public System.Byte[] GetBmp(System.Int32 quality)public System.Byte[] GetJpeg(System.Int32 quality)public Color GetPixel(System.Int32 x, System.Int32 y)public System.Byte[] GetPng()public Editor.Pixmap Resize(System.Int32 x, System.Int32 y)public Editor.Pixmap Resize(Vector2 size)public System.Boolean SaveJpg(System.String filename, System.Int32 quality = 70)public System.Boolean SavePng(System.String filename)public System.Void Scroll(System.Int32 x, System.Int32 y, Sandbox.Rect r)public System.Void Scroll(System.Int32 x, System.Int32 y)public System.Boolean UpdateFromPixels(Sandbox.Bitmap bitmap)public System.Boolean UpdateFromPixels(System.ReadOnlySpan`1<System.Byte> data, System.Int32 width, System.Int32 height, Sandbox.ImageFormat format = 12)public System.Boolean UpdateFromPixels(System.ReadOnlySpan`1<System.Byte> data, Vector2 size, Sandbox.ImageFormat format = 12)Propertiespublic System.Boolean Editor.Pixmap.HasAlpha { get; set; }public System.Int32 Editor.Pixmap.Height { get; set; }public Vector2 Editor.Pixmap.Size { get; set; }public System.Int32 Editor.Pixmap.Width { get; set; }Metadata