Can anybody help

BlitzMax Forums/BlitzMax Programming/Can anybody help

This will work as long as none of the color parameters are set to - 0.
It kind of a workaround, but it seems to work

Graphics 640, 480, 0
'Loading an Masked Image, where the top right pixel
'will be set as the maske color
'!! Mask colors must be from 1-255 for each channel 

Local maskImg:TImage = LoadImageMasked("DarkRed.png")
Local maskImg1:TImage = LoadImageMasked("DarkRed.png")
Local maskImg2:TImage = LoadImageMasked("DarkRed.png")

While Not KeyDown(KEY_ESCAPE)
	Cls
	SetBlend MASKEBLEND
	DrawImage maskImg,0,0
	DrawImage maskImg1,0,64
	DrawImage maskImg2,0,128
	Flip
Wend
End

Function LoadImageMasked:TImage(imgName:String)
	Local img:TImage = LoadImage(imgName)
	Local pm:TPixmap = LockImage(img) 
	Local px:Int = ReadPixel(pm,ImageWidth(img)-1,1)
	Local r:Byte = px Shr 16
	Local g:Byte = px Shr 8
	Local b:Byte = px
	
	'If The mask color is the same then skip SetMaskColor
	'With out this only every other img if same mask color
	'will work
	If r<>0 And g<>0 And b<>0 Then
		SetMaskColor(r,g,b)
	End If
	
	'Clean Up
	img = Null
	pm = Null
	px = Null
	r = Null
	g = Null
	b = Null
	GCCollect
	Return LoadImage(imgName,MASKEDIMAGE)
End Function