Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Color value of an existing pixel

Status
Not open for further replies.

mario51t

Technical User
Dec 10, 2003
9
0
0
US
I need to know the color value of a pixel in an existing jpg image. I did not find any solution in the .NET class library. While I have found two third party packages that claim to be able to do it, I'd like to avoid adding DLLs if possible. Anyone knows of a way to do this within VB.NET?

TIA, /Mario
 
Yes.. it is possible...
Look over the following code snip. It is used to capture the pixle color when the mouse is clicked on a spot in a picturebox.. (I was using it to select a transpancy color for a bitmap...)


Have fun
Code:
    Private Sub pBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pBox1.MouseUp
        If Not pBox1.Image Is Nothing Then
            Dim bmp As New Bitmap(pBox1.Image)
            Try
                PictureBox1.BackColor = bmp.GetPixel(e.X, e.Y)
            Catch
            End Try
        End If
    End Sub


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top