Image Mask

BlitzMax Forums/BlitzMax Beginners Area/Image Mask

KnupK(Posted 2007) [#1]
Thats me again.
Explame please how to mask image?
Mask color is not black.


tonyg(Posted 2007) [#2]
setmaskcolor r,g,b


JazzieB(Posted 2007) [#3]
You need to set the mask colour before loading your image(s), as it's applied at load time and not draw time.


KnupK(Posted 2007) [#4]
It not works ='(

Here the code i use:

Graphics 640,480,16

SetMaskColor 225,0,255
Global gfx_image:TImage = LoadImage("media\player.png",MASKEDIMAGE)

Type player
Field x#,y#
Field image:TImage

Global playerList:TList

Function Create(x#,y#)
If playerList = Null Then playerList =CreateList()
p:player = New player
ListAddLast playerList,p
p.x# = x#
p.y# = y#
p.image = gfx_image
End Function

Function Update()
If playerList Then
For p:player = EachIn playerList
DrawImage p.image,p.x#,p.y#
Next
EndIf
End Function
End Type

player.Create(300,200)

Repeat

player.Update

Flip
Cls

Until KeyHit(KEY_ESCAPE) Or AppTerminate()


tonyg(Posted 2007) [#5]
Can you post an example image?
My guess is the colour is not 255,0,255 as you're loading in 16bit mode. Try 32bit mode and see what happens.


KnupK(Posted 2007) [#6]
No,bmax still drawing maskcolor

Example image:
http://www.gamedev.ru/download/?id=5033


tonyg(Posted 2007) [#7]
The image has an alphachannel (I think that's what it is called)
<edit> I had to turn it off in my paint package and resave.
I thought drawing with ALPHABLEND would fix it but it didn't.