Advertisement
Guest User

k4biXs Color Picker 1.3.3

a guest
Jul 7th, 2013
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'Copyright by k4biX
  2. Public Class Form1
  3.     Dim MouseState As Boolean = False
  4.  
  5.     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  6.         Dim BMP As New Drawing.Bitmap(1, 1)
  7.         Dim GFX As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(BMP)
  8.         GFX.CopyFromScreen(New Drawing.Point(MousePosition.X, MousePosition.Y), _
  9.         New Drawing.Point(0, 0), BMP.Size)
  10.         Dim Pixel As Drawing.Color = BMP.GetPixel(0, 0)
  11.  
  12.         CPpanel.BackColor = Color.FromArgb(HScrollBar1.Value, hsbR.Value, hsbG.Value, hsbB.Value)
  13.         RedC.Text = Pixel.R
  14.         GreenC.Text = Pixel.G
  15.         BlueC.Text = Pixel.B
  16.         HexC.Text = RGB2HTMLColor(Pixel.R, Pixel.G, Pixel.B)
  17.         SAMPC.Text = RGB2SAMPColor(Pixel.R, Pixel.G, Pixel.B)
  18.         TextBox2.Text = RGB2Embedd(Pixel.R, Pixel.G, Pixel.B)
  19.  
  20.         hsbR.Value = Pixel.R
  21.         hsbG.Value = Pixel.G
  22.         hsbB.Value = Pixel.B
  23.     End Sub
  24.  
  25.     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
  26.         CPpanel.BackColor = Color.FromArgb(HScrollBar1.Value, hsbR.Value, hsbG.Value, hsbB.Value)
  27.  
  28.         RedC.Text = hsbR.Value
  29.         GreenC.Text = hsbG.Value
  30.         BlueC.Text = hsbB.Value
  31.         TextBox1.Text = HScrollBar1.Value
  32.  
  33.         HexC.Text = RGB2HTMLColor(hsbR.Value, hsbG.Value, hsbB.Value)
  34.         SAMPC.Text = RGB2SAMPColor(hsbR.Value, hsbG.Value, hsbB.Value)
  35.         TextBox2.Text = RGB2Embedd(hsbR.Value, hsbG.Value, hsbB.Value)
  36.     End Sub
  37.  
  38.     Public Function RGB2HTMLColor(ByVal R As Byte, ByVal G As Byte, _
  39.    ByVal B As Byte) As String
  40.         Dim HexR, HexB, HexG As Object
  41.         Dim sTemp As String
  42.         On Error GoTo ErrorHandler
  43.         HexR = Hex(R)
  44.         If Len(HexR) < 2 Then HexR = "0" & HexR
  45.         HexG = Hex(G)
  46.         If Len(HexG) < 2 Then HexG = "0" & HexG
  47.         HexB = Hex(B)
  48.         If Len(HexB) < 2 Then HexB = "0" & HexB
  49.         RGB2HTMLColor = "#" & HexR & HexG & HexB
  50. ErrorHandler:
  51.     End Function
  52.  
  53.     Public Function RGB2SAMPColor(ByVal R As Byte, ByVal G As Byte, _
  54. ByVal B As Byte) As String
  55.         Dim HexR, HexB, HexG, HexA As Object
  56.         Dim sTemp As String
  57.         On Error GoTo ErrorHandler
  58.         HexR = Hex(R)
  59.         If Len(HexR) < 2 Then HexR = "0" & HexR
  60.         HexG = Hex(G)
  61.         If Len(HexG) < 2 Then HexG = "0" & HexG
  62.         HexB = Hex(B)
  63.         If Len(HexB) < 2 Then HexB = "0" & HexB
  64.         HexA = Hex(HScrollBar1.Value)
  65.         RGB2SAMPColor = "0x" & HexR & HexG & HexB & HexA
  66. ErrorHandler:
  67.     End Function
  68.  
  69.     Public Function RGB2Embedd(ByVal R As Byte, ByVal G As Byte, _
  70. ByVal B As Byte) As String
  71.         Dim HexR, HexB, HexG As Object
  72.         Dim sTemp As String
  73.         On Error GoTo ErrorHandler
  74.         HexR = Hex(R)
  75.         If Len(HexR) < 2 Then HexR = "0" & HexR
  76.         HexG = Hex(G)
  77.         If Len(HexG) < 2 Then HexG = "0" & HexG
  78.         HexB = Hex(B)
  79.         If Len(HexB) < 2 Then HexB = "0" & HexB
  80.         RGB2Embedd = "{" & HexR & HexG & HexB & "}"
  81. ErrorHandler:
  82.     End Function
  83.  
  84.     Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _spektrum.Click
  85.         If (MouseState = True) Then
  86.             Timer1.Stop()
  87.             MouseState = False
  88.         Else
  89.             Timer1.Start()
  90.             MouseState = True
  91.         End If
  92.     End Sub
  93.  
  94.     Private Sub PictureBox1_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _spektrum.MouseEnter
  95.         Me.Cursor = Cursors.Cross
  96.         If (MouseState = True) Then
  97.             Timer1.Start()
  98.             MouseState = True
  99.         Else
  100.             Timer1.Stop()
  101.             MouseState = False
  102.         End If
  103.     End Sub
  104.  
  105.     Private Sub PictureBox1_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _spektrum.MouseLeave
  106.         Me.Cursor = Cursors.Default
  107.         If (MouseState = True) Then
  108.             Timer1.Stop()
  109.             MouseState = False
  110.         Else
  111.             Timer1.Stop()
  112.             MouseState = False
  113.         End If
  114.     End Sub
  115. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement