EditableImage

Up and coming: shot check knows this class and its members today, and programs run it once the native runtime lands.

ShotInstancenot creatablecomingImages and GPU

Up and coming

Draw, crop, resize and recolour pictures in memory, then save them or send their bytes anywhere.

An EditableImage is one RGBA buffer with Roblox's EditableImage members, the same names and shapes, none of which yield. On top of those come pixel reads, thick lines, crop and alpha crop, resize, hue shift, PNG bytes and saving. ImageService:LoadAsync opens one from a path or a file's bytes, and AssetService makes an empty one or loads one by asset id.

Properties

NameTypeDefaultDescription
SizeVector2read-onlyWidth and height in pixels; read-only.

Methods

NameArgumentsReturnsDescription
ReadPixelsBuffer(position: Vector2, size: Vector2)bufferReturns a rectangle's pixels as RGBA8 bytes, row by row from the top left, as Roblox lays them out; never yields.
WritePixelsBuffer(position: Vector2, size: Vector2, pixels: buffer)()Same name and arguments as Roblox's WritePixelsBuffer; it never yields.
DrawRectangle(position: Vector2, size: Vector2, color: Color3, transparency: number, combineType: ImageCombineType)()Same arguments as Roblox's DrawRectangle; combineType is BlendSourceOver, Overwrite, AlphaBlend, Add or Multiply.
DrawCircle(center: Vector2, radius: number, color: Color3, transparency: number, combineType: ImageCombineType)()Same name and arguments as Roblox's DrawCircle; it never yields.
DrawLine(p1: Vector2, p2: Vector2, color: Color3, transparency: number, combineType: ImageCombineType)()Same name and arguments as Roblox's DrawLine; it never yields.
DrawImage(position: Vector2, image: EditableImage, combineType: ImageCombineType)()Same arguments as Roblox's DrawImage; combineType is BlendSourceOver, Overwrite, AlphaBlend, Add or Multiply.
GetPixel(position: Vector2)(Color3, number)Returns a pixel's colour and its alpha from 0 to 1; positions count from 0, as in ReadPixelsBuffer.
SetPixel(position: Vector2, color: Color3, alpha: number?)()
DrawThickLine(p1: Vector2, p2: Vector2, thickness: number, color: Color3, transparency: number?)()Draws a soft-edged line of the given thickness from p1 to p2; it never yields.
Crop(position: Vector2, size: Vector2)EditableImageReturns the rectangle at position and size as a new image.
GetVisibleBounds()(Vector2?, Vector2?)Returns the first and last pixel whose alpha is above 0, or nil for a fully transparent image.
AlphaCrop()(EditableImage, Vector2)Returns the image cut to GetVisibleBounds, and the offset it was cut at.
Resize(size: Vector2, filter: ("Nearest" | "Bilinear")?)EditableImageReturns the image at a new size without yielding; the Nearest filter is a pixelated rescale.
ResizeAsync
yields
(size: Vector2)(EditableImage?, string?)Resizes with a Lanczos filter, for shrinking photos and generated images, and waits for the result.
HueShift(turns: number)()Turns the hue by a number of turns, so 0.5 is 180 degrees; alpha is kept.
EncodePng()bufferReturns the image as PNG bytes for an upload or a data URI, with no temporary file.
SaveAsync
yields
(path: string)(boolean, string?)Writes a .png, .jpg, .bmp or .tga file, by the path's extension, and waits until it is written.
From ShotInstance 33