On Fri, 07 Dec 2007 06:25:55 -0800, <za***@construc tion-imaging.comwrot e:
[...]
There is no builtin .NET code to do zooming, but it can be
accomplished by setting the Top and Left properties of the picturebox
to be outside of the form.
I think I would call that "panning". :)
The PictureBox does offer some minimal control over basic zooming
behavior. For anything more complicated than that, a custom control would
be required. Based on what little I know about WPF, using WPF is probably
the easiest way. But it wouldn't be hard to write a custom control that
handles it either.
Drawing oneself, you would presumably be using the Graphics.DrawIm age()
method to draw the bitmap on the screen, in the form. To scale (zoom)
and/or offset (pan) the drawing, you can simply provide destination
dimensions for the image that are different from the source dimensions
(zoom in, dimensions are larger, zoom out, smaller...pan down and/or
right, origin of destination is to the left or up from the visible origin
in the control, and vice a versa). Alternatively, one can modify the
effective viewport being used to draw by creating a new transformation
matrix and assigning it to the Transform property of the Graphics instance
being used to draw.
Of course, you also need to provide a UI to control zoom and pan. That's
an entirely separate matter. But a standard click-and-drag or
scrollbar-based UI is fairly straightforward .
Pete