Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
_SETALPHA Question
#8
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
Reply


Messages In This Thread
_SETALPHA Question - by TerryRitchie - 09-29-2023, 04:08 AM
RE: _SETALPHA Question - by DSMan195276 - 09-29-2023, 04:21 AM
RE: _SETALPHA Question - by TerryRitchie - 09-29-2023, 04:33 AM
RE: _SETALPHA Question - by TerryRitchie - 09-29-2023, 05:01 AM
RE: _SETALPHA Question - by SMcNeill - 09-29-2023, 05:15 AM
RE: _SETALPHA Question - by TerryRitchie - 09-29-2023, 05:39 AM
RE: _SETALPHA Question - by SMcNeill - 09-29-2023, 07:19 AM
RE: _SETALPHA Question - by SMcNeill - 09-29-2023, 07:24 AM
RE: _SETALPHA Question - by DSMan195276 - 09-29-2023, 05:11 PM
RE: _SETALPHA Question - by TerryRitchie - 09-29-2023, 05:21 PM
RE: _SETALPHA Question - by TerryRitchie - 09-29-2023, 06:19 PM
RE: _SETALPHA Question - by SMcNeill - 09-29-2023, 06:41 PM
RE: _SETALPHA Question - by SMcNeill - 09-29-2023, 06:56 PM
RE: _SETALPHA Question - by TerryRitchie - 09-29-2023, 07:07 PM
RE: _SETALPHA Question - by TerryRitchie - 09-30-2023, 03:37 AM
RE: _SETALPHA Question - by SMcNeill - 09-30-2023, 11:19 AM
RE: _SETALPHA Question - by TerryRitchie - 09-30-2023, 02:00 PM



Users browsing this thread: 6 Guest(s)