Here is the function I am using to set the image mask
Function SetImageMask(p_image:TImage, p_red:Int,p_green:Int,p_blue:Int)
Local l_maskrgb:Int
Local l_maskargb:Int
Local l_pixelrgb:Int
Local l_pixelraw:Int
Local l_x:Int,l_y:Int
Local l_pix1:Tpixmap
l_maskrgb = p_red Shl 16 + p_green Shl 8 + p_blue
l_pix1 = LockImage(p_image)
For l_x = 0 To ImageWidth(p_image)-1
For l_y = 0 To ImageHeight(p_image)-1
l_pixelraw = ReadPixel(l_pix1,l_x,l_y)
l_pixelrgb = l_pixelraw & 16777215
If l_pixelrgb = l_maskrgb Then
' make transparent
WritePixel(l_pix1,l_x,l_y,l_maskrgb)
Else
' remove transparency
Local l_PixelNoAlpha:Int=l_pixelrgb | (255 Shl 24)
WritePixel(l_pix1,l_x,l_y,l_PixelNoAlpha)
End if
Next
next
UnlockImage(p_image)
End function
|