Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8920673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:20:09+00:00 2026-06-15T06:20:09+00:00

I got a picbox in my function which store the image as bitmap, i

  • 0

I got a picbox in my function which store

the image as bitmap,

i now need a function that can

find out the colour RGB components of any given pixel when i move my mouse on to it

what should i do to get this?


I have success to display the RGB and pixel in selected textbox
but when i move my mouse out side of the picture box
there’s error msg came out:

Parameter must be positive and < Width.
Parameter name: x

i try to use If e.X > 300 Then e.X = 300
but it said “e.X” is for read only

My Code current looks like this:

    If pixBox1.Image Is Nothing Then Exit Sub
    txtColourPixel.Text = String.Format("x,y = {0},{1}; Color={2}", e.X, e.Y, DirectCast(pixBox1.Image, Bitmap).GetPixel(e.X, e.Y).ToString)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T06:20:10+00:00Added an answer on June 15, 2026 at 6:20 am

    You COULD do it like this:

    UPDATE: SOMETIMES the Move handler gives coordinates OUTSIDE of the actual image. Oned could handle this, or just ignore:

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim ofd As New OpenFileDialog
        ofd.ShowDialog()
        PictureBox1.ImageLocation = ofd.FileName
    End Sub
    
    Private Sub PictureBox1_MouseMove(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseMove
        If PictureBox1.Image Is Nothing Then Exit Sub
        Try
            TextBox1.Text = String.Format("x,y = {0},{1}; Color={2}", e.X, e.Y, DirectCast(PictureBox1.Image, Bitmap).GetPixel(e.X, e.Y).ToString)
        Catch ex As ArgumentOutOfRangeException
            ' this can happen, we just swallow it and show an error text
            TextBox1.Text = "out of bounds"
        End Try
    End Sub
    

    GetPixel is the method you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Got a seg fault from my memcpy that gdb can't give me anything else
Got a real simple question but can't figure out the solution. Got following code.
got a question, is it possible to hide image and show iframe which are
Got some code here that isn't working: $(#sidebar ul li:last).each(function(){ $(this).addClass(last); }); Basically I
I got this issue with displaying a image that i allready have added as
Got a really tricky problem that I've been trying to figure out for a
got a simple web site, in html. I do a simple function to move
got a problem, can't get my head around this jquery and would appreciate your
got some problems. Built an applet that has to be used step-by-step. After each
Got a problem with my add function to my database. The following code hangs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.