Sound & Images > Images


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


Create Images

Create Blank Image

blank-image-block

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

new BitmapData([NUMBER] * Engine.SCALE, [NUMBER] * Engine.SCALE, true, 0)

Copy of Image

copy-image-block

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

[IMAGE].clone()

Part of Image

part-image-block

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

getSubImage([IMAGE], [NUMBER], [NUMBER], [NUMBER], [NUMBER])

Resized Copy of Image

resize-image-block

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.

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

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

From the Game

Current Screen as Image

screen-image-block

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.

captureScreenshot()

Image from Actor

actor-image-block

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

getImageForActor([ACTOR])

From External Sources

Image from File

file-image-block

Returns an image that is loaded from a file. Images must be placed into the extras subfolder of your game.

getExternalImage([TEXT])

Load Image from URL

url-image-block

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 {
  [ACTIONS]
});

Convert Image to/from Text

Image to Text

to-text-image-block

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

imageToText([IMAGE])

Text to Image

from-text-image-block

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

imageFromText([TEXT])