I have loaded the image in the picture box. I have clicked with mouse at a point on the image and get the pixel value for that point (using e.x and e.y). now i zoom the image.

How to get the pixel of the same point in zoomed position on run time. (I don't want to click again at the same position after zoomed). zoom the image by adding 50 to picture box width and height.

//picturebox mouse click
Color pixel = mybitmap1.GetPixel(e.x, e.y);

Thanks in advance......

Recommended Answers

All 5 Replies

Are you wanting to get the 'new' position of the pixel you zoomed in on or are you wanting to get the new pixel at the zoomed in position?

If you're wanting to do the second one, could you not create a variable that holds the x and y of the mouse position? Then when you click, you set this value and then use it for all of your pixel checks?

Hi Resnymph,

Thanks for replay. Iam waiting for 1st one.

For second one i am storing the x and y in a rectangle. How can i use this value after zoomed in or out?.

Well depending on how you zoom your image depends on how to get the resized position.

What you'll need to do is store your pixel somewhere outside the scope of the click / zoom function (like a member or global variable).

Then, if you're just wanting the new pixel at the resized position (for example you always want to find the middle pixel of the image), you just do the following:

Color pixel = mybitmap.GetPixel([I]X[/I],[I]Y[/I])

where X and Y are your stored variables.

If you want your original pixel's in the resized image, you'll need to transform the original location by how you resize your image.

Hope this helps

that it how do i get that. Iam placing the image in the center by getting the screen resolution with picture box size as (800, 650). now iam increasing width and height by 50 and using the offset(-25, -9) to maintain the image on top location.

What will be the equation to get the original pixel after zoomed the image.


I got the Answer....thnks Resnymph

ratio = picturebox.Width/original image width

rectangle.X = value (of x)/ratio.
rectangle.Y = value (of Y)/ratio.
rectangle.Width = value (of width)/ratio.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.