GetSpritePointer

Top  Previous  Next

Syntax

UINT = GetSpritePointer(sprite as POINTER)

Description

Returns a pointer to the first memory location used by the sprites image. The image is stored on a DirectX surface buffer.

Parameters

sprite - Sprite pointer returned by LoadSprite.

Return value

The address of the first pixel of the sprite

Remarks

Used for direct memory access of a sprites buffer. The buffer must be locked first with the LockSprite command and unlocked with the UnlockSprite command after access is completed. You must be sure never to write outside the confines of the buffer, that is the dimensions of the sprite image.

The return value is actually a UINT. To use with a POINTER a variable must be defined first.

See Also: LOADSPRITE, LOCKSPRITE, GETSPRITEPITCH, UNLOCKSPRITE

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