Images > Images

Read our Image API guide for an explanation of these blocks.

Image API settings

Toggle Image API Auto-scaling

enable image api auto scaling

Set whether Image API output is scaled automatically. This is set to true by default. This setting affects how all the blocks below work.

When this is enabled, the coordinates and dimensions passed to all Image API blocks will be scaled by Engine.SCALE. By settings this to false, you can use the Image API blocks to manipulate images on a per-pixel basis, no matter how your game is upscaled.

imageApiAutoscale = true;
imageApiAutoscale = false;

Create Images

Create Blank Image

blank image with w int h int

Create a blank image of the specified width and height. Usually assigned to an Image attribute right away.

newImage([INT], [INT])

Copy of Image

copy of image

Returns a copy of the specified image. This is a true copy, so altering the copy will not affect the original.


Part of Image

part of image x int y int w int h int

Returns the specified part of the image as a new image.

getSubImage([IMAGE], [INT], [INT], [INT], [INT])

Resized Copy of Image

copy of image at w number % h number % using smoothing

Returns a larger (or smaller) copy of the image. Width and height are given as percentages - 100% means keep it the same, 200% means double, 50% means half.

resizeImage([IMAGE], ([NUMBER]/100), ([NUMBER]/100), true)

//No Smoothing
resizeImage([IMAGE], ([NUMBER]/100), ([NUMBER]/100), false)

From the Game

Current Screen as Image

current screen as image

Captures the current screen as an image and returns that. This takes time (it may pause the game for a a tenth of a second), so use it sparingly.


Image from Actor

image from actor

Returns the current image for the specified actor. (In other words, the exact visual state of the actor at the time that you use this.)


From External Sources

Image from File

image from file text

Returns an image that is loaded from a file. Images must be placed into the extras subfolder of your game. Some blocks require the images to be saved with transparency enabled to work properly.


Load Image from URL

load image from url text and then do...

Returns an image that is loaded from a URL. When the image successfully loads, the enclosed blocks will run. Use the embedded the image block to refer to the loaded image. If the image does not load, the enclosed blocks will not run.

For a Flash game you may need to give permissions to access the web.

loadImageFromURL([TEXT], function(img:BitmapData):Void {

Convert Image to/from Text

Image to Text

image as text

Converts an image into text form and returns that. Useful for storing image data on servers (via an HTTP request). This takes time to run (a split second or longer).


Text to Image

text as image

Returns an image that was converted to text using the prior block. This takes time to run (a split second or longer).