Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'Copyright by k4biX
- Public Class Form1
- Dim MouseState As Boolean = False
- Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
- Dim BMP As New Drawing.Bitmap(1, 1)
- Dim GFX As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(BMP)
- GFX.CopyFromScreen(New Drawing.Point(MousePosition.X, MousePosition.Y), _
- New Drawing.Point(0, 0), BMP.Size)
- Dim Pixel As Drawing.Color = BMP.GetPixel(0, 0)
- CPpanel.BackColor = Color.FromArgb(HScrollBar1.Value, hsbR.Value, hsbG.Value, hsbB.Value)
- RedC.Text = Pixel.R
- GreenC.Text = Pixel.G
- BlueC.Text = Pixel.B
- HexC.Text = RGB2HTMLColor(Pixel.R, Pixel.G, Pixel.B)
- SAMPC.Text = RGB2SAMPColor(Pixel.R, Pixel.G, Pixel.B)
- TextBox2.Text = RGB2Embedd(Pixel.R, Pixel.G, Pixel.B)
- hsbR.Value = Pixel.R
- hsbG.Value = Pixel.G
- hsbB.Value = Pixel.B
- End Sub
- Private Sub hsb_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles HScrollBar1.Scroll, hsbR.Scroll, hsbG.Scroll, hsbB.Scroll
- CPpanel.BackColor = Color.FromArgb(HScrollBar1.Value, hsbR.Value, hsbG.Value, hsbB.Value)
- RedC.Text = hsbR.Value
- GreenC.Text = hsbG.Value
- BlueC.Text = hsbB.Value
- TextBox1.Text = HScrollBar1.Value
- HexC.Text = RGB2HTMLColor(hsbR.Value, hsbG.Value, hsbB.Value)
- SAMPC.Text = RGB2SAMPColor(hsbR.Value, hsbG.Value, hsbB.Value)
- TextBox2.Text = RGB2Embedd(hsbR.Value, hsbG.Value, hsbB.Value)
- End Sub
- Public Function RGB2HTMLColor(ByVal R As Byte, ByVal G As Byte, _
- ByVal B As Byte) As String
- Dim HexR, HexB, HexG As Object
- Dim sTemp As String
- On Error GoTo ErrorHandler
- HexR = Hex(R)
- If Len(HexR) < 2 Then HexR = "0" & HexR
- HexG = Hex(G)
- If Len(HexG) < 2 Then HexG = "0" & HexG
- HexB = Hex(B)
- If Len(HexB) < 2 Then HexB = "0" & HexB
- RGB2HTMLColor = "#" & HexR & HexG & HexB
- ErrorHandler:
- End Function
- Public Function RGB2SAMPColor(ByVal R As Byte, ByVal G As Byte, _
- ByVal B As Byte) As String
- Dim HexR, HexB, HexG, HexA As Object
- Dim sTemp As String
- On Error GoTo ErrorHandler
- HexR = Hex(R)
- If Len(HexR) < 2 Then HexR = "0" & HexR
- HexG = Hex(G)
- If Len(HexG) < 2 Then HexG = "0" & HexG
- HexB = Hex(B)
- If Len(HexB) < 2 Then HexB = "0" & HexB
- HexA = Hex(HScrollBar1.Value)
- RGB2SAMPColor = "0x" & HexR & HexG & HexB & HexA
- ErrorHandler:
- End Function
- Public Function RGB2Embedd(ByVal R As Byte, ByVal G As Byte, _
- ByVal B As Byte) As String
- Dim HexR, HexB, HexG As Object
- Dim sTemp As String
- On Error GoTo ErrorHandler
- HexR = Hex(R)
- If Len(HexR) < 2 Then HexR = "0" & HexR
- HexG = Hex(G)
- If Len(HexG) < 2 Then HexG = "0" & HexG
- HexB = Hex(B)
- If Len(HexB) < 2 Then HexB = "0" & HexB
- RGB2Embedd = "{" & HexR & HexG & HexB & "}"
- ErrorHandler:
- End Function
- Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _spektrum.Click
- If (MouseState = True) Then
- Timer1.Stop()
- MouseState = False
- Else
- Timer1.Start()
- MouseState = True
- End If
- End Sub
- Private Sub PictureBox1_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _spektrum.MouseEnter
- Me.Cursor = Cursors.Cross
- If (MouseState = True) Then
- Timer1.Start()
- MouseState = True
- Else
- Timer1.Stop()
- MouseState = False
- End If
- End Sub
- Private Sub PictureBox1_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _spektrum.MouseLeave
- Me.Cursor = Cursors.Default
- If (MouseState = True) Then
- Timer1.Stop()
- MouseState = False
- Else
- Timer1.Stop()
- MouseState = False
- End If
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement