"Reverse Transparency"

BlitzMax Forums/BlitzMax Beginners Area/"Reverse Transparency"

Eric Vaughn(Posted 2006) [#1]
Hello,

I was wondering if BlitzMax has a function or if one can be created that makes all of the colors in an image transparent except for one in a sort of "reverse transparency."

Any ideas?


Grisu(Posted 2006) [#2]
It has no function for that as far as I know.
But you can always code your own... ;)

Here's the idea:

1.
Mask the image with the color to be excluded

2.
Draw the resulting image to a temp one of the same size and with a plain bg color of 255,0,255 for instance.

3.
Compare each pixel of the temp image with the original one.
If the pixel of the temp image doesn't match 255,0,255 then copy the pixel from the original image over to the temp image.

4.
Finally mask the new temp image with 255,0,255 and you have your image.


Yan(Posted 2006) [#3]
Soemthing like...
Local keppColour = $FF0000
Local pixmap:TPixmap = image.Lock(frame, True, True)

For Local x=0 Until pixmap.width
	For Local y=0 Until pixmap.height
		Local argb = ReadPixel(pixmap, x, y)
		
		If argb & $FFFFFF = keepColour
			WritePixel(pixmap, x, y, argb)
		Else
			WritePixel(pixmap, x, y, argb & $FFFFFF)
		EndIf
	
	Next
Next
??


JustLuke(Posted 2006) [#4]
OT:

Grisu, shouldn't your Steve Irwin tribute read "greatest hunter" rather than "greastest"?


Grisu(Posted 2006) [#5]
@Yan:
Yepp, something like that I meant... ;)

@Luke:
Yeah, but I wanted to give my sig a personal touch, i.e. Grisu => Greasy => Greastest. Was lame ok ok. :)