How to use SetMaskColor ?
BlitzMax Forums/BlitzMax Beginners Area/How to use SetMaskColor ?
| ||
Hi all, I'm still testing BlitzMax =) I've created a picture with a white background. I tried to use SetMaskColor to make the background transparent. But it doesn't work. I also loaded the image with the MASKEDIMAGE flag. Can you help me? Thanks, gamble |
| ||
SetMaskColor needs to be called before you load the image -or- create the image. If it still doesn't work then two things are likely 1) you're not specifying the correct RGB - ie 255,255,255 (there is no 256,256,256 as the range is 0-255). 2) the white in your image isn't pure white! but nearly white... check if it really is by using a paint package eye dropper tool or by using blitzmax to grab a colour at x,y. |
| ||
This is how to use SetMaskColor:Strict '** Constants ** Const WIDTH:Int = 640 Const HEIGHT:Int = 480 Const DEPTH:Int = 0 '** End Constants ** Graphics WIDTH, HEIGHT, DEPTH SetMaskColor 255, 255, 255 Local testImage:TImage = LoadImage("testImage.bmp", MASKEDIMAGE) MidHandleImage testImage DrawImage testImage, WIDTH / 2, HEIGHT / 2 Flip FlushMem WaitKey End Maybe the backgroudcolor of your image isn't really white, open up in Paint or something and check it. Nicolas. |
| ||
Hi, thanks for your fast replys. I've found the error: I've taken the wrong file format. I didn't know BMax doesn't like png's :-) Bye gamble |
| ||
Will document this more: The problem was if you were using 32 bit png files (as in opposed to 24 bit ones) BlitzMax assumes the mask is already present in the alpha channel of the file and does not overwrite it by making transparent all pixels set to the maskcolor. It does mean however that if you can get to grips with how to edit the alpha channel in your paint program you can leave the mask color stuff behind altogether. |
| ||
I've also got a setimagemask routine in the graphics section of the codearchives you can use. |