Class
EditableImage
Object which allows for the runtime creation and manipulation of images.
About EditableImage
EditableImage allows for the runtime creation and manipulation of images.
To create a blank EditableImage, use
AssetService.CreateEditableImage. To create an EditableImage from
an existing image, use AssetService.CreateEditableImageAsync.
EditableImage can be used in any Content property which takes an
image, such as ImageLabel.ImageContent or
MeshPart.TextureContent. This is done by setting the content property
to Datatype.Content.fromObject(editableImage).
The EditableImage coordinate system is relative to the top left of the
image:
- Top-left:
(0, 0) - Bottom-right:
(Size.X - 1, Size.Y - 1)
When you use AssetService.PromptCreatePlatformContentAsync to
publish an object that has a Content property which references an
EditableImage, the editable image is published as an image and the property
is set to a new asset ID.
Update Limitations
Only a single EditableImage can be updated per frame on the display side.
For example, if you update three EditableImage objects which are currently
being displayed, it will take three frames for all of them to be updated.
Enabling for Published Experiences
For security purposes, using EditableImage fails by default in published
games. To enable it, open the
Creator Dashboard, go to the
game's Configure ⟩ Settings, and toggle on Enable Mesh / Image
APIs. Alternatively, in Studio, open Experience Settings and toggle on
Allow Mesh / Image APIs under Security. Remember to review the
Terms of Use
before enabling the toggle.
Permissions
To prevent misuse, AssetService.CreateEditableImageAsync only allows
you to load and edit image assets if any of the following is true:
- Owned by or explicitly shared with the experience owner.
- Owned by or explicitly shared with the logged in Studio user.
- Owned by or explicitly shared with the logged in player if the
EditableImageis on the client side. - Owned by a group where the experience owner, Studio user, or player has a role with permission to edit the group's assets. See Roles and permissions for more information.
See Grant permissions to learn how to share assets with users or groups.
The APIs throw an error if they are used to load an asset that does not meet the criteria above.
Memory Limits
Editable assets are currently expensive for memory usage. To minimize its
impact on client performance, EditableImage has strict client-side memory
budgets, although the server, Studio, and plugins operate with unlimited
memory. Linking one EditableImage to multiple image-related
Content data types (multi-referencing) can help with memory
optimization.
Properties 1
Size
: Vector2ReadOnlyNotReplicatedSize of theEditableImagein pixels.Size of the
EditableImagein pixels. The maximum size is 1024×1024. AnEditableImagecannot be resized; this property is read-only. In order to resize or crop an image, create a newEditableImageand useDrawImageTransformed()to transfer the contents; then callDestroy().
Methods 10
Destroy
() → ()Destroys the image contents and immediately reclaims the memory they use.Destroys the contents of the image, immediately reclaiming used memory.
DrawCircle
(center: Vector2, radius: int, color: Color3, transparency: float, combineType: ImageCombineType, antiAliasing: AntiAliasing = Enabled) → ()Draws a circle at the specified point.Draws a circle at the specified point on the
EditableImage. If the circle is semi-transparent, it will be blended with the pixels behind it using source over blending.DrawImage
(position: Vector2, image: EditableImage, combineType: ImageCombineType) → ()Draws anotherEditableImageinto thisEditableImageat the given position.Draws another
EditableImageinto thisEditableImageat the given position. Positions outside the canvas bounds are allowed such that only part of the new image is drawn.DrawImageProjected
(projectionSource: Object, projection: Dictionary, brushConfig: Dictionary) → ()Projects anotherEditableImageonto a surface using anEditableMeshor preparedWrapTextureTransferand stores the result on thisEditableImage.Projects another
EditableImageonto the surface defined byprojectionSourceand stores the result on thisEditableImageusing the source's UV mapping and the specified projection and brush configuration.projectionSourceaccepts anEditableMeshor aWrapTextureTransfer.When passing a
WrapTextureTransfer, first callWrapTextureTransfer.PrepareProjectionMeshDataAsyncand wait for it to complete successfully.SampleImageProjected
(projectionSource: Object, sourceTexture: EditableImage, projectionConfig: Dictionary, brushConfig: Dictionary) → ()Projects pixels from a texture into thisEditableImageusing anEditableMeshor preparedWrapTextureTransfer.Projects the pixels in
sourceTexture, using the geometry and UV mapping ofprojectionSource, onto thisEditableImage.projectionSourceaccepts anEditableMeshor aWrapTextureTransfer. This is the inverse ofDrawImageProjected(): it reads from the mesh texture and writes the sampled pixels into this image in place.Only mesh surfaces facing the projector and within the projection volume are sampled. When multiple mesh surfaces project to the same destination pixel, the closest surface is used. This makes the method suitable for sampling a brush-sized region, modifying it in place, and then using
DrawImageProjected()to write it back onto a texture.When passing a
WrapTextureTransfer, first callWrapTextureTransfer.PrepareProjectionMeshDataAsyncand wait for it to complete successfully.DrawImageTransformed
(position: Vector2, scale: Vector2, rotation: float, image: EditableImage, options: Dictionary?) → ()Draws an image into thisEditableImagewith transformations including scaling and rotation, placing it at the specified position.This method lets you draw an
EditableImageinto thisEditableImagewith transformations applied, such as scaling and rotation. The position parameter specifies where the pivot point of the source image will be placed on this image after transformations. Positions outside the canvas bounds are allowed such that only part of the new image is drawn.DrawLine
(p1: Vector2, p2: Vector2, color: Color3, transparency: float, combineType: ImageCombineType, antiAliasing: AntiAliasing = Enabled) → ()Draws a line between two provided points.Draws a line on the
EditableImageone pixel thick between the two provided points.DrawRectangle
(position: Vector2, size: Vector2, color: Color3, transparency: float, combineType: ImageCombineType) → ()Draws a rectangle of the given size at the given top-left position.Draws a rectangle on the
EditableImageof the given size at the given top-left position.ReadPixelsBuffer
(position: Vector2, size: Vector2) → bufferReads a rectangular region of pixels into a buffer.Reads a rectangular region of pixels from an
EditableImageand returns it as a buffer. Each number in the buffer is a single byte, with pixels stored in a sequence of four bytes (red, green, blue, and alpha).Note that this method uses alpha instead of transparency, unlike the
EditableImagedrawing methods.WritePixelsBuffer
(position: Vector2, size: Vector2, buffer: buffer) → ()Writes a rectangular region of pixels into the image.Writes a rectangular region of pixels to an
EditableImagefrom a buffer. Each number in the buffer is a single byte, with pixels stored in a sequence of four bytes (red, green, blue, and alpha).Note that this method uses alpha instead of transparency, unlike the
EditableImagedrawing methods.
Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.