Nilai RGB dari Warna
Fungsi RGB di Visual Basic digunakan untuk mengkonversi suatu rangkaian bilangan integer menjadi bilangan kode untuk format warna. Lalu bagaimana jika ingin membalikkan fungsi tersebut (mengubah bilangan kode warna menjadi bilangan kode-kode RGB).
Berikut ini contoh kode untuk mengetahui nilai RGB dari kontrol Picture (BackColor) :
[ VB 6.0 ]
Dim Warna As Long
Warna = Picture1.BackColor
Dim R As Integer, G As Integer, B As Integer
R = Warna And (Not &HFFFFFF00)
G = (Warna And (Not &HFFFF00FF)) \ &H100&
B = (Warna And (Not &HFF00FFFF)) \ &HFFFF&
MsgBox "Nilai Red = " & R
MsgBox "Nilai Green = " & G
MsgBox "Nilai Blue = " & B
Warna = Picture1.BackColor
Dim R As Integer, G As Integer, B As Integer
R = Warna And (Not &HFFFFFF00)
G = (Warna And (Not &HFFFF00FF)) \ &H100&
B = (Warna And (Not &HFF00FFFF)) \ &HFFFF&
MsgBox "Nilai Red = " & R
MsgBox "Nilai Green = " & G
MsgBox "Nilai Blue = " & B
[ VB .NET ]
Dim Warna As Color
Warna = PictureBox1.BackColor
MsgBox("Nilai Red = " & Warna.R)
MsgBox("Nilai Green = " & Warna.G)
MsgBox("Nilai Blue = " & Warna.B)
Warna = PictureBox1.BackColor
MsgBox("Nilai Red = " & Warna.R)
MsgBox("Nilai Green = " & Warna.G)
MsgBox("Nilai Blue = " & Warna.B)
0 Komentar:
Posting Komentar
Pengunjung yang baik selalu meninggalkan jejak berupa komentar. :)
Berlangganan Posting Komentar [Atom]
<< Beranda