Re: vb.net get pixel color
Oh my gosh. Did you really use the string representation of a color from ToString() to extract the RGB values instead of the R, G, and B properties???
Code:
red = color.Substring(color.IndexOf("R=") + 2)
color = red
red = red.Substring(0, red.IndexOf(","))
green = color.Substring(color.IndexOf("G=") + 2)
color = green
green = green.Substring(0, green.IndexOf(","))
blue = color.Substring(color.IndexOf("B=") + 2)
blue = blue.Substring(0, blue.IndexOf("]"))
Code:
TextBox1.Text = bm.GetPixel(curPixelX, curPixelY).ToString()
RGB_breakerBuster(TextBox1.Text, r1, g1, b1)
Please fix that...
Re: vb.net get pixel color
Re: vb.net get pixel color
Yes, and you didn't implement it. At all.
Re: vb.net get pixel color
you have 2 options :
1 wait for me to implement (remember I am lazy)
2 DIY
Re: vb.net get pixel color
I would assume that you would implement it, since it involves only copying and pasting 5 lines of code into your own, but apparently not.
(I would never use this code in the first place, so those aren't my options, by the way.)
Re: vb.net get pixel color
Quote:
Originally Posted by
minitech
I would assume that you would implement it, since it involves only copying and pasting 5 lines of code into your own, but apparently not.
(I would never use this code in the first place, so those aren't my options, by the way.)
is that your way of asking me to add pink ?
Re: vb.net get pixel color
Re: vb.net get pixel color
Code:
Public Class Form1 ' code amped by .paul
Dim curPixelX As Integer = 0
Dim curPixelY As Integer = 0
Dim r1, g1, b1 As Integer
Dim curColorChar As Char = Nothing
Dim bm As Bitmap
Sub RGB_breakerBuster(ByVal inColor As Color, ByRef red As Integer, ByRef green As Integer, ByRef blue As Integer)
' returns value of red,green,blue in a pixel of a bitmap as integers
red = inColor.R
green = inColor.G
blue = inColor.B
End Sub
Public Function getPixelColor(ByVal r As Integer, ByVal g As Integer, ByVal b As Integer) As Char
' r= red, g = green, b = blue
Dim colorchar As Char
If r > 245 And g > 245 And b > 245 Then
colorchar = "w" ' white
ElseIf r < 20 And g < 20 And b < 20 Then
colorchar = "k" ' black (kuro in japanese)
ElseIf r > g And g > b And g < 100 Then
colorchar = "r" ' red
ElseIf r > g And g > b And g > 200 Then
colorchar = "y" ' yellow
ElseIf r > g And g > b And 100 < g < 200 Then
colorchar = "o" 'orange
ElseIf (g > r And r > b) Or (g > b And b > r) Then
colorchar = "g" 'green
ElseIf b > g And g > r Then
colorchar = "b" 'blue
ElseIf (b > r And r > g) Or (r > b And g < 20) Then
colorchar = "v" ' violet
Else
colorchar = "u" ' yet undefined
End If
Return colorchar
End Function
Sub colorLegend()
' converts color char to the color name
' label2 = getPixelColor(r1, g1, b1) 1st colorchar
' label3 = color represented by colorchar
Select Case Label2.Text
Case "w"
Label3.Text = "white"
Case "k"
Label3.Text = "black"
Case "r"
Label3.Text = "red"
Case "y"
Label3.Text = "yellow"
Case "o"
Label3.Text = "orange"
Case "g"
Label3.Text = "green"
Case "b"
Label3.Text = "blue"
Case "v"
Label3.Text = "violate"
Case Else
End Select
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Try
TextBox1.Text = bm.GetPixel(curPixelX, curPixelY).ToString()
RGB_breakerBuster(bm.GetPixel(curPixelX, curPixelY), r1, g1, b1)
TextBox2.Text = r1 & " " & g1 & " " & b1
bm.SetPixel(curPixelX, curPixelY, Color.Black)
PictureBox1.Image = bm
curPixelX += 1
Label2.Text = getPixelColor(r1, g1, b1)
colorLegend()
Catch ex As Exception
Timer1.Enabled = False
MsgBox("done")
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Enabled = Not Timer1.Enabled
bm = PictureBox1.Image
curPixelY = bm.Height \ 2
End Sub
End Class
Re: vb.net get pixel color
Violate? I think that violates the rules defining the standard colors ;) A quick question - what is the significance of the name RGB_breakerBuster? Why do you need a Sub to even do that? Another one - what is the Timer for??
Re: vb.net get pixel color
violet is in the visible spectrum, was it mispelled, meh
RGB_breakerBuster breakes down the pixel color string to the red, green blue color value (as integer)
just like in mortal kombat the breakerBuster breakes the opponents combo
since when do I answer why questions ?
Quote:
what is the Timer for??
run the program