Image Mask

BlitzMax Forums/BlitzMax Beginners Area/Image Mask

Thats me again.
Explame please how to mask image?
Mask color is not black.

setmaskcolor r,g,b

You need to set the mask colour before loading your image(s), as it's applied at load time and not draw time.

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()

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.

No,bmax still drawing maskcolor

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

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.