0

I have drawn an image in a panel. When I check a 'Magnify' check box and place mouse cursor over the panel, the rectangle area covering the cursor should be magnified. How can I do it? I searched Codeproject.com and did not find such one.

y_zyx
  • 582
  • 4
  • 10
  • 28
  • http://stackoverflow.com/questions/5950730/cursor-magnifier-c-net http://stackoverflow.com/questions/5947942/zoom-in-out-images-in-c You keep on asking the same question again and again. Just stick to a single question and do not expect us to do everything for you. – Emond May 11 '11 at 12:58

2 Answers2

2

This is how you do this in WPF

In WinForms it is not that easy but still doable. You have to add the control on top of the picturebox and move it around with the cursor (and adjust the origin in of the image in the magnifier to move along).

Emond
  • 50,210
  • 11
  • 84
  • 115
0

I did something similar a long time ago but I don't know if it was the best approach or better approaches exist today. I determined a mapping of my viewing area by magnification strength to individual pixels. Each pixel on the regular image represented a small Rectangle of varying size depending on magnification level and it had the same color attribute as the pixel as well.

I figured out how many Pixel Rectangles I could fit in my viewing area and then used that to figure out the snapshot rectangle size on the original. I read through every pixel top to left until I reached bottom left, and in the snapshot creating these rectangles for each pixel and placing them in the viewing area image one after the other.

It worked decently well and was pretty fast but I had to double buffer the viewing image panel to get updates. A big problem with this approach was that I couldn't zoom out from the original.

Like I said I am sure their are better ways to do this as I was just whipping something together at the last minute.

maple_shaft
  • 10,435
  • 6
  • 46
  • 74