Sub Colorpicker_ValueChanged (Value As Paint)
Dim ColorInt As Int = fx.Colors.To32Bit(Value)
Dim HexARGB As String = Bit.ToHexString(ColorInt)
Dim HexRGB As String = HexARGB.SubString2(2,8)
hexColor = "#"& HexRGB
intColor = Bit.ParseInt(HexRGB, 16)
Dim Red As Byte = Bit.ShiftRight(Bit.And(intColor, Bit.ShiftLeft(0xff, 16)), 16)
Dim Green As Byte = Bit.ShiftRight(Bit.And(intColor, Bit.ShiftLeft(0xff, 8)), 8)
Dim Blue As Byte = Bit.And(intColor, 0xff)
Dim NewBlue As Int = Bit.And(Bit.ShiftRight(Blue, 3), 0x1f)
Dim NewGreen As Int = Bit.ShiftLeft(Bit.And(Bit.ShiftRight(Green, 2), 0x3f), 5)
Dim NewRed As Int = Bit.ShiftLeft(Bit.And(Bit.ShiftRight(Red, 3), 0x1f), 11)
Dim Color565 As Int = Bit.Or(Bit.Or(NewRed, NewGreen), NewBlue)
End Sub