09-29-2023, 07:24 AM
You can always do something like this, if you really just need to change alpha for a whole range at once for a _RGB color:
Code: (Select All)
OPTION _EXPLICIT
SCREEN _NEWIMAGE(640, 480, 32)
'|
'| Fade in a red box test
'|
DIM RedBox AS LONG
DIM c AS INTEGER
RedBox = _NEWIMAGE(320, 240, 32)
_DEST RedBox
CLS , _RGB32(255, 0, 0)
_DEST 0
c = 0
DO
CLS
_LIMIT 30
ChangeAllAlpha c, _RGB32(255, 0, 0), RedBox
_PUTIMAGE (159, 119), RedBox
_DISPLAY
_LIMIT 30
c = c + 1
LOOP UNTIL c = 256
SUB ChangeAllAlpha (Alpha AS _UNSIGNED _BYTE, Kolor AS _UNSIGNED LONG, Image AS LONG)
DIM AS _MEM m
DIM AS _OFFSET o
DIM AS _UNSIGNED _BYTE r, r1, g, g1, b, b1
m = _MEMIMAGE(Image)
r = _RED32(Kolor): g = _GREEN32(Kolor): b = _BLUE32(Kolor)
o = m.OFFSET
$CHECKING:OFF
DO UNTIL o >= m.OFFSET + m.SIZE
_MEMGET m, o + 2, r1
_MEMGET m, o + 1, g1
_MEMGET m, o, b1
IF r = r1 AND g = g1 AND b = b1 THEN _MEMPUT m, o + 3, Alpha
o = o + 4
LOOP
$CHECKING:ON
_MEMFREE m
END SUB