このリンクを読みましたConverting 8 bit color into RGB value
次に、次のような VB.NET コードを試しました。
Private Sub picturebox1_MouseDown(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles picturebox1.MouseDown
Dim bm As New Bitmap(picturebox1.Image)
Dim Red As Byte = bm.GetPixel(e.X, e.Y).R
Dim Green As Byte = bm.GetPixel(e.X, e.Y).G
Dim Blue As Byte = bm.GetPixel(e.X, e.Y).B
Dim ColorNumber As Byte = ((Red / 32) << 5) + ((Green / 32) << 2) + (Blue / 64)
' Show Byte Number of color
MsgBox(ColorNumber)
MsgBox(Red & ":" & Green & ":" & Blue)
Red = (ColorNumber >> 5) * 32
Green = ((ColorNumber >> 2) << 3) * 32
Blue = (ColorNumber << 6) * 64
MsgBox(Red & ":" & Green & ":" & Blue)
End Sub
しかし、1 つのピクセルを選択すると、エラーが発生します。
算術演算でオーバーフローが発生しました。
256 色 (8 ビット) のイメージのバイト値を取得し、(変換) 結果のバイト値を RGB 値に復元するにはどうすればよいですか。
ありがとう :)