Skip to content

CreateImage

Narta Xaymar Dirks edited this page Nov 25, 2026 · 8 revisions

CreateImage BlitzBasic

CreateImage:Int32 width:Int32, height:Int32, frames:Int32=1
Parameter Mode Type Default Description
width In Int32 required Width of one frame in pixels.
height In Int32 required Height of one frame in pixels.
frames In Int32 1 Number of frames. Defaults to 1.

Returns: A handle for the image.

Description

Creates an empty image that is filled with black, which is the default mask color and so draws as transparent. Draw into it by making it the current buffer with ImageBuffer. An image can hold several frames of the same size next to each other, such as the steps of an animation, which are chosen with the frame number of DrawImage.

Differences

  • A graphics window must be open, because images live in video memory. A size that is zero or negative stops the program with an error.

Examples

Graphics 320, 240, 0, 2
SetBuffer BackBuffer()
Local img = CreateImage(64, 64, 8)
For f = 0 To 7
	SetBuffer ImageBuffer(img, f)
	Color 255, 200, 40
	Oval 0, 0, 64, 64, 1
	Color 0, 0, 0
	Oval 16 + f * 4, 8 + f, 24, 40, 1
Next
SetBuffer BackBuffer()
Local n = 0
While n < 40
	Cls
	Color 255, 255, 255
	DrawImage img, 128, 88, (n / 2) Mod 8
	Text 160, 190, "frame " + ((n / 2) Mod 8), 1, 1
	Flip
	n = n + 1
Wend

Media

CreateImage

Related Commands

CopyImage BlitzBasic, DrawImage BlitzBasic, FreeImage BlitzBasic, GrabImage BlitzBasic, HandleImage BlitzBasic, LoadAnimImage BlitzBasic, LoadImage BlitzBasic, MaskImage BlitzBasic

Home · Command Index


Getting started

Language

Tools


Language Features
BlitzBasic
Blitz3D
BlitzPlus
Differences

More

Clone this wiki locally