GetR, GetG, GetB and GetAlpha functions?

Monkey Forums/Monkey Beginners/GetR, GetG, GetB and GetAlpha functions?

Pakz(Posted 2015) [#1]
Does anyone have functions that I can use that convert the image pixel array value into the red green blue and alpha value?

I have a function already that converts red and green and blue and alpha to the array value.

    Function argb:Int(r:Int, g:Int, b:Int ,alpha:Int=255)
        Return (alpha Shl 24) | (r Shl 16) | (g Shl 8) | b          
    End Function 



therevills(Posted 2015) [#2]
Have a look at the CreateImages method in this code:

http://www.monkey-x.com/Community/posts.php?topic=3488#36692

		ReadPixels(pixels, 0, 0, image.Width(), image.Height())
		
		' convert the mask colour (black) to alpha
		For Local i:Int=0 Until image.Width() * image.Height()
			Local argb:Int = pixels[i]
			Local a:Int = (argb Shr 24) & $ff
			Local r:Int = (argb Shr 16) & $ff
			Local g:Int = (argb Shr 8) & $ff
			Local b:Int = argb & $ff

			If a = 255 And r = 0 And g = 0 And b = 0 Then
				a = 0
				argb = (a Shl 24) | (r Shl 16) | (g Shl 8) | b
				pixels[i] = argb
			End
		Next



Pakz(Posted 2015) [#3]
Thanks for the code :)

I was looking around for functions with google and I got scared of the weird characters use like >> for java. The code here looks more friendly.