s&box docs

public class Editor.Pixmap

A pixel map, or just a simple image.

Constructors

Showing 2 constructors

Methods

Showing 18 methods

public void Clear(Color color)

Fill the pixel map with given color.

protected virtual override void Finalize()

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

Create a pixmap from a bitmap

public static Editor.Pixmap FromFile(string filename)

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

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

Create a pixmap from a texture.

Parameters

  • withAlpha: Default: True

public byte[] GetBmp(int 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.

public byte[] GetJpeg(int 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.

Parameters

  • quality: JPEG quality, 0 to 100.

public Color GetPixel(int x, int y)

public 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.

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

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

Parameters

  • filename: A full, valid absolute target path. Will not create directories on its own.
  • quality: JPEG quality, 0 to 100. Default: 70

Returns

Whether the file was created or not.

public bool SavePng(string filename)

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

Parameters

  • filename: A full, valid absolute target path. Will not create directories on its own.

Returns

Whether the file was created or not.

Properties

Showing 4 properties

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

Whether this pixel map supports the alpha channel.

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

Height of the pixel map.

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

THe size of this pixel map.

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

Width of the pixel map.

Metadata

FieldValue
NamespaceEditor
Typeclass
AssemblySandbox.Tools
Doc IDT:Editor.Pixmap

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