GLBasic User Manual

Main sections

SPRITE2MEM()

ok% = SPRITE2MEM(pixels%[], num%)



Reads the pixels of the sprite num% into the data array of integers. The gained pixels are in the format of 0xAABBGGRR (see MEM2SPRITE).

In order to access each pixel now, you use:
LOCAL r%,g%,b%,a%

LOCAL abgr% = pixels%[x + y*width]
r = bAND(abgr, 0xff)
g = bAND(ASR(abgr,8), 0xff)
b = bAND(ASR(abgr,16), 0xff)
a = bAND(ASR(abgr,24), 0xff)

// write back to array
pixels%[x + y*width] = bOR(RGB(r,g,b), ASL(a, 24) )

See also...