Maskimage with b+?
BlitzPlus Forums/BlitzPlus Programming/Maskimage with b+?
I need to mask an image with a transpareny colour. But when I draw it on screen the background is always displayed "black"...
Someone told me to call a "user32.dll" to get the current window color. - Is there an easier way?
Right now I have painted the image background grey so it fits the windowcolour on my PC. But thats only bad cheating... :(
In graphics mode it works fine for me, but since you are talking about grey as your window color i suppose you are creating windows and gadgets?
yes, exactly
Here's the code I use atm for displaying the image:
Global cwdb_logo=LoadImage("cwdb.png"): MaskImage cwdb_logo,0,0,0
CW_Logo=CreateCanvas(542,16,55,55,CD_window,1)
SetBuffer CanvasBuffer(CW_logo)
DrawImage cwdb_logo,0,0
FlipCanvas cw_logo
first off loading an image black is always transparent by default so you don't need to set it as the mask colour.
Second - the reason the background is black is that is the default colour for a canvas. if you draw a rect or use the clscolor along with a cls, then you can change the colour of the background.
To make it the same as the desktop you need to use a userlib to get the window colour (since people can change their windows properties)
To do this you use the send message command. I can't remember how to do this though, am having a look.
lo Grisu it's me again.
Create a file in notepad that looks something like this:
.lib "user32.dll"
GetSysColor%(Color%)
Save it as BlitzPlus\userlibs\user32.decls
Then, in your game, to get the colour of a window face..
Global winr, wing, winb
winrgb=GetSysColor(5)
winr = winrgb Shr 16 And $FF
wing = winrgb Shr 8 And $FF
winb = winrgb And $FF
.
.
SetBuffer Canvasbuffer(can)
ClsColor winr, wing, winb
Cls
.
.
More on the GetSysColor
HEREHi Cyberseth,
Do you have your rgb values in the right order there?
I played around with GetSysColor and found that it returned the color in BGR format. See my example in the link above.
Oops I believe you're right! ;)
Well, I tested Seth's example code and I now I have a white background instead of a black one. - At least some visual progress, but something is wrong with that! :))))))))))))))
@Syntax:
Will check it.
International Karate rocks! Anyone working on a remake??? :)
International Karate rocks! Anyone working on a remake??? :)
I was thinking about it.. then I found it for my GBA :P
Hi, Syntax Error... did you draw the karateka animation above?
I could use some (and pay) some low-resolution graphics like that.
/R
Grisu, change GetSysColor(5) to GetSysColor(15). Sorry about that!
Try B+ 1.11 and see if you still have the same problem. I found a huge problem with B+ 1.35 NOT masking the color I tell it to on my old laptop with a 4mb graphics card (see previous post (blank full screen) wheras it works perfectly in B2D and earlier versions of B+. This is a very serious problem for distribution of software. Also try changing the graphics driver and see if that works