UNLOCKSPRITE

Top  Previous  Next

Syntax

INT = UNLOCKSPRITE(sprite as POINTER)

Description

Unlocks a previously locked sprite.

Parameters

sprite - Sprite pointer returned by LoadSprite.

Return value

The current lock count of the sprite or -1 on error.

Remarks

A locked sprite allows direct access to the image memory using standard pointers. Every call to LOCKSPRITE must be paired with a call to UNLOCKSPRITE or sprite drawing will fail.

See Also: LOCKSPRITE, LOADSPRITE, GETSPRITEPITCH, GETSPRITEPOINTER

Example usage

DEF pBuffer as POINTER
sprite1 = LOADSPRITE(GETSTARTPATH+"bug.bmp",0,0,3)
LOCKSPRITE sprite1
pitch = GETSPRITEPITCH sprite1
pBuffer = GETSPRITEPOINTER sprite1
'Change the first pixel of the sprite to red
#<UINT>pBuffer = RGBToScreen(RGB(255,0,0))
'Change the first pixel on the next line to green
pBuffer += pitch
#<UINT>pBuffer = RGBToScreen(RGB(0,255,0))
UNLOCKSPRITE sprite1