Skip to content

LoadAnimImage

Narta Xaymar Dirks edited this page Oct 28, 2026 · 6 revisions

Blitz3DBlitzPlusBlitzBasic

LoadAnimImage

LoadAnimImage:Int32 bmpfile:String, cellwidth:Int32, cellheight:Int32, first:Int32, count:Int32
Parameter Mode Type Default Description
bmpfile In String required
cellwidth In Int32 required Width of one frame.
cellheight In Int32 required Height of one frame.
first In Int32 required Number of the first frame in the sheet, usually 0.
count In Int32 required How many frames to cut out.

Returns: A handle for the image, or 0 if the file could not be loaded or the frame size does not fit.

Description

Loads a picture file that contains several frames next to each other and cuts it into the frames of one image. Frames are counted from left to right, then from top to bottom, and each is cellwidth by cellheight pixels. Choose one with the frame number of DrawImage.

The example makes its own sheet first with CreateImage and SaveImage, so that it needs no other file.

Animated pictures. With a cellwidth or cellheight of 0, an animated GIF, animated WebP or animated AVIF file loads as its frames, packed into a sheet: ImageWidth and ImageHeight are the size of one frame, ImageFrames is how many there are, and ImageFrameDelay is how long each lasts. first and count then choose some of the frames (a count of 0 is all the rest). The sheet is at most 8192 pixels wide and high; an animation that needs more is not loaded and a warning says so. A file that is not animated fails to load as before. Animated PNG (APNG) is intentionally not supported and counts as a plain PNG.

Examples

Graphics 320, 240, 0, 2
SetBuffer BackBuffer()
; Four frames of 32x32 next to each other, saved as a 128x32 picture.
Local sheet = CreateImage(128, 32)
SetBuffer ImageBuffer(sheet)
For f = 0 To 3
	Color 60 + f * 60, 200 - f * 40, 80
	Oval f * 32 + 16 - f * 3, 16 - f * 3, f * 6 + 2, f * 6 + 2, 1
Next
SetBuffer BackBuffer()
SaveImage sheet, "sheet.bmp"
Local anim = LoadAnimImage("sheet.bmp", 32, 32, 0, 4)
Cls
For f = 0 To 3
	DrawImage anim, 40 + f * 60, 100, f
Next
Flip
WaitKey

Related Commands

CopyImage, CreateImage, DrawImage, FreeImage, GrabImage, HandleImage, LoadImage, MaskImage

Home · Command Index



Differences
Language Features
BlitzBasic
Blitz3D
BlitzPlus

Clone this wiki locally