Draw pictures all white?
BlitzMax Forums/BlitzMax Beginners Area/Draw pictures all white?
| ||
| 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 |
| ||
| 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
|
| ||
| 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. |
| ||
| Why don't you just load a very small white image (eg: 32x32) and use it for all your "white drawing" needs? |
| ||
| 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)
|
| ||
| 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) |
| ||
| A combination of TomToad's and slenkar's ideas should do what you are looking for. |