Draw pictures all white?

BlitzMax Forums/BlitzMax Beginners Area/Draw pictures all white?

ima747(Posted 2010) [#1]
I have images, some are all black transparent PNGs, some are colored transparent PNGs, I can daw them all black by setting the draw color to black (0,0,0), but I need to draw them all white, and draw color white is just normal colorization. Is there a simple way to draw them solid (alpha blendable and respecting the PNG's transparent pixels) white


TWH(Posted 2010) [#2]
I don't understand the question. Can you show us the PNGs?

If you have an image with no alpha-layer/channel then you can use SetMaskColor before loading like this:

Graphics 640,480,0,0,2
SetMaskColor(255,255,255) // White is transparent
Local img:TImage = LoadImage("transparency.png", MASKEDIMAGE)
While Not KeyHit(KEY_ESCAPE)
	DrawImage img,MouseX(),MouseY()
	Flip
	Cls
Wend



ima747(Posted 2010) [#3]
Take any normal alpha png (image with transparent bits). Setcolor to 0,0,0 and draw the image. It comes out solid black (combine with alpha for shadows by the way). I need that same solid effect, but white instead of black.


Gabriel(Posted 2010) [#4]
Why don't you just load a very small white image (eg: 32x32) and use it for all your "white drawing" needs?


TomToad(Posted 2010) [#5]
Just create a new image and fill it with white, copying the alpha from the original image.


Not tested, but should produce the image you need.
Local NormalImageWithAlpha:TImage = LoadImage("MyImage.png")
Local WhiteImageWithAlpha:TImage = CreateImage(NormalImageWithAlpha.Width,NormalImageWithAlpha.Height)

Local Pix1:TPixmap = LockImage(NormalImageWithAlpha)
Local Pix2:TPixmap = LockImage(WhiteImageWithAlpha)

For Local x:Int = 0 Until NormalImageWithAlpha.Width
	For Local y:Int = 0 Until NormalImageWithAlpha.Height
		WritePixel(Pix2,x,y,ReadPixel(Pix1,x,y) | $FFFFFF)
	Next
Next

UnlockImage(WhiteIMageWithAlpha)
UnlockImage(NormalImageWithAlpha)



slenkar(Posted 2010) [#6]
you could draw a white rectangle over the image

then set the rectangles alpha to a low value, (the image is going white)
then raise the alpha of the rectangle to 1 (the image is white)


Jesse(Posted 2010) [#7]
A combination of TomToad's and slenkar's ideas should do what you are looking for.