Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to Color Mask?
#1
So how do we make color masks with the "newer" commands?   The old put and get method makes sense but I am clueless as to how to get it to work with _putimage. 

Alpha blending????  How's the color not overwrite the black pixels? Help!

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), i&
_PutImage (200, 100), i2&
_PrintString (10, 150), "So how do you do a color mask"
_PrintString (10, 159), " with _putimage?"
Reply
#2
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?"
Reply
#3
Thank you. I mostly want to be able to do simple recolors of an image without doing a full recolor. In the past white mask and color overlays and black wasn't touched. Doesn't alpha blending color any pixels under an area?
Reply
#4
I have code that switches one color to another in an image, how 'bout that?

Your request for a "mask" threw me off.
b = b + ...
Reply




Users browsing this thread: 1 Guest(s)