12-31-2024, 11:46 AM
I've swapped lines 28 and 29 of your example above, so the red filled square ist put first, then set the white (color 15) parts in the original image as transparent and put it over the colored one. This works for this specific example, doesn't mean it's the general way to go. If you wanna work with alphablending you would need to go with 32bit images anyways, alpha is not possibe in SCREEN 13 or 256 color images, here you can only define one color as fully transparent with the _CLEARCOLOR statement.
Code: (Select All)
'How to mask?
a$ = SPACE$(4 + 100)
b$ = SPACE$(4 + 100)
i& = _NEWIMAGE(10, 10, 256)
i2& = _NEWIMAGE(10, 10, 256)
SCREEN 13
LOCATE 1, 1: PRINT "Base image"
LINE (40, 40)-(49, 49), 15, B
GET (40, 40)-(49, 49), a$
_PUTIMAGE (0, 0)-(9, 9), 0, i&, (40, 40)-(49, 49)
SLEEP
LOCATE 1, 1: PRINT "Color Mask"
LINE (40, 40)-(49, 49), 12, BF
GET (40, 40)-(49, 49), b$
_PUTIMAGE (0, 0)-(9, 9), 0, i2&, (40, 40)-(49, 49)
SLEEP
CLS
_PRINTSTRING (10, 10), "Put & And "
PUT (200, 10), a$, PSET
PUT (200, 10), b$, AND
_PRINTSTRING (10, 50), "_Putimage & And "
_PUTIMAGE (200, 50), i&
PUT (200, 50), b$, AND
_PRINTSTRING (10, 100), "_Putimage & _Putimage "
_PUTIMAGE (200, 100), i2&
_CLEARCOLOR 15, i&
_PUTIMAGE (200, 100), i&
_PRINTSTRING (10, 150), "So how do you do a color mask"
_PRINTSTRING (10, 159), " with _putimage?"
GuiTools, Blankers & other Projects:
https://qb64phoenix.com/forum/forumdisplay.php?fid=32
Libraries & useful Functions:
https://qb64phoenix.com/forum/forumdisplay.php?fid=23
https://qb64phoenix.com/forum/forumdisplay.php?fid=32
Libraries & useful Functions:
https://qb64phoenix.com/forum/forumdisplay.php?fid=23