Api Editor Pixmap
class

Pixmap

public class Pixmap

A pixel map, or just a simple image.

Constructors

Pixmap(Int32 width, Int32 height)

Create a new empty pixel map. It can then be drawn to via the Paint class, like so: var myPixMap = new Pixmap( 16, 16 ); Paint.Target( myPixMap ); Paint.Antialiasing = true; Paint.ClearPen(); Paint.SetBrush( Color.Red ); Paint.DrawRect( new Rect( 0, myPixMap.Size ), 2 ); Paint.Target( null );

Pixmap(Vector2 size)

Properties

Name Type Description
Width Int32 Width of the pixel map.
Height Int32 Height of the pixel map.
HasAlpha Boolean Whether this pixel map supports the alpha channel.
Size Vector2 THe size of this pixel map.

Methods

static Pixmap FromFile(String filename)

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

static Pixmap FromBitmap(Bitmap bitmap)

Create a pixmap from a bitmap

static Pixmap FromTexture(Texture texture, Boolean withAlpha = True)

Create a pixmap from a texture.

Void Clear(Color color)

Fill the pixel map with given color.

Void Scroll(Int32 x, Int32 y, Rect r)

Duplicate a sub-rectangle of the image at re-draw it at given coordinates.

x — Position to re-draw the duplicated image at on the X axis, from the left edge.
y — Position to re-draw the duplicated image at on the Y axis, from the top edge.
r — The area on the image to duplicate.
Void Scroll(Int32 x, Int32 y)

Duplicate the entire image and re-draw it at given coordinates.

x — Position to re-draw the duplicated image at on the X axis, from the left edge.
y — Position to re-draw the duplicated image at on the Y axis, from the top edge.
Pixmap Resize(Vector2 size)

Returns a new pixel map that contains resized version of this image with given dimensions. Will try to preserve aspect ratio.

Pixmap Resize(Int32 x, Int32 y)
Boolean UpdateFromPixels(ReadOnlySpan<Byte> data, Int32 width, Int32 height, ImageFormat format = 12)
Boolean UpdateFromPixels(Bitmap bitmap)

Copy from a bitmap

Boolean UpdateFromPixels(ReadOnlySpan<Byte> data, Vector2 size, ImageFormat format = 12)
Byte[] GetPng()

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.

Boolean SavePng(String filename)

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

filename — A full, valid absolute target path. Will not create directories on its own.
returns — Whether the file was created or not.
Boolean SaveJpg(String filename, Int32 quality = 70)

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

filename — A full, valid absolute target path. Will not create directories on its own.
quality — JPEG quality, 0 to 100.
returns — Whether the file was created or not.
Byte[] GetJpeg(Int32 quality)

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.

quality — JPEG quality, 0 to 100.
Byte[] GetBmp(Int32 quality)

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.

Color GetPixel(Int32 x, Int32 y)
Assembly: Sandbox.Tools Namespace: Editor Full Name: Editor.Pixmap