Transparency problems

BlitzMax Forums/BlitzMax Beginners Area/Transparency problems

vinians(Posted 2010) [#1]
Hi guys! Im creating a generic image load to my game. I want to use pixel (0,0) as transparency color, so the image can be created with any transparency color you just need to put it at pixel 0, 0. So I tryed this code:
	Method add_image(sFile:String)
		Local im:TImage
		im = LoadImage(sFile, MASKEDIMAGE | FILTEREDIMAGE | DYNAMICIMAGE)
		If Not im
			Print "Error reading " + sFile
			Return
		EndIf
		Local px:TPixmap
		px = LockImage(im, 0)
		mask_color = ReadPixel(px, 0, 0)
		UnlockImage(im)
		
		SetMaskColor(mask_color & $FF0000, mask_color & $00FF00, mask_color & $FF)
		im = LoadImage(sFile, MASKEDIMAGE | FILTEREDIMAGE | DYNAMICIMAGE)
		If Not Images Then Images = New TList
		Images.AddLast(im)
	EndMethod

I tryed to store pixel(0,0) color to use onn SetMaskColor() function but its sems to work only if you define it BEFORE load a image. So what Im doing is reading the image, getting the color of (0,0) pixel and reload, SetMaskColor and then reload the image.
What is wrong with this not working code?
Thanks in advance


TomToad(Posted 2010) [#2]
Change
SetMaskColor(mask_color & $FF0000, mask_color & $00FF00, mask_color & $FF)

to
SetMaskColor((mask_color & $FF0000) Shr 16, (mask_color & $00FF00) Shr 8, mask_color & $FF)


vinians(Posted 2010) [#3]
Hey thanks man!!!
Worked like a dream :D
flw!