Sub Process_Globals
Type clr(a As Int, r As Int, g As Int, b As Int)
Dim cols As clr
End Sub
SplitColors(thisColor)
a = cols.a
r = cols.r
g = cols.g
b = cols.b
Sub SplitColors(x As Long)
cols.Initialize
Dim a, r, g, b As Int
Dim a0, r0, g0 As Long
cols.a = Floor(x / Power(2,24))
r0 = x Mod Power(2,24)
cols.r = Floor(r0 / Power(2,16))
g1 = r0 Mod Power(2,16)
cols.g = Floor(g0 / Power(2,8))
cols.b = cols.g Mod Power(2,8)
End Sub
Sub Globals
Type TARGBColor(Alpha, Red, Green, Blue As Int)
End Sub
Sub CnvtByteToInt( aByte As Byte) As Int
Dim Num As Int
Num = aByte
If aByte < 0 Then Num = Num + 256
Return Num
End Sub
Sub GetColors( aColor As Int)
Dim Conv As ByteConverter 'From ByteConverter library
Dim bytes(8) As Byte
Conv.LittleEndian = False 'Force it to False so we are sure
bytes = Conv.IntsToBytes(Array As Int(aColor))
Dim ARGBColor As TARGBColor
ARGBColor.Initialize
ARGBColor.Alpha = CnvtByteToInt(Bytes(0))
ARGBColor.Red = CnvtByteToInt(Bytes(1))
ARGBColor.Green = CnvtByteToInt(Bytes(2))
ARGBColor.Blue = CnvtByteToInt(Bytes(3))
Log("[GetColors] "&ARGBColor)
Return ARGBColor
End Sub
Sub Activity_Create(FirstTime As Boolean)
Dim argb() As Int
argb = GetARGB(Colors.Transparent)
Log("A = " & argb(0))
Log("R = " & argb(1))
Log("G = " & argb(2))
Log("B = " & argb(3))
End Sub
Sub GetARGB(Color As Int) As Int()
Dim res(4) As Int
res(0) = Bit.UnsignedShiftRight(Bit.And(Color, 0xff000000), 24)
res(1) = Bit.UnsignedShiftRight(Bit.And(Color, 0xff0000), 16)
res(2) = Bit.UnsignedShiftRight(Bit.And(Color, 0xff00), 8)
res(3) = Bit.And(Color, 0xff)
Return res
End Sub
Dim Colr as integer = System.Drawing.ColorTranslator.ToWin32(Color.Red)
'returns a color from an integer
Sub GetARGB(Color As Int) As Int()
Dim res(4) As Int
res(0) = Bit.UnsignedShiftRight(Bit.AND(Color, 0xff000000), 24) 'A (transparency)
res(1) = Bit.UnsignedShiftRight(Bit.AND(Color, 0xff0000), 16) 'R
res(2) = Bit.UnsignedShiftRight(Bit.AND(Color, 0xff00), 8) 'G
res(3) = Bit.AND(Color, 0xff) 'B
Return res
End Sub
L1Colr = Fn.getargb(Colr)
rt.color2(Colors.RGB(L1Colr(1), L1Colr(2), L1Colr(3)), "{1}")
'returns a color from an integer
Sub GetARGB(Color As Int) As Int()
Dim res(4) As Int
res(3) = Bit.UnsignedShiftRight(Bit.AND(Color, 0xff000000), 24) 'B
res(2) = Bit.UnsignedShiftRight(Bit.AND(Color, 0xff0000), 16) 'G
res(1) = Bit.UnsignedShiftRight(Bit.AND(Color, 0xff00), 8) 'R
res(0) = Bit.AND(Color, 0xff) 'A (transparency)
Return res
End Sub