Image Viewer ...

F

Frank Uray

Hi all

I need to do a image viewer, just to view and zoom pictures
in jpeg. I do not need to edit or save the picture.

I am sure, there are some controls already made.
I am thankful for any comment on that !

Best regards
Frank Uray
 
M

Michael Nemtsev [MVP]

Hello Frank,

You need to use GDI+ for this.
Use MSDN for more info and google to find samples how to use it
http://www.c-sharpcorner.com/UploadFile/mahesh/gdi_plus12092005070041AM/gdi_plus.aspx

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo


FU> Hi all
FU>
FU> I need to do a image viewer, just to view and zoom pictures in jpeg.
FU> I do not need to edit or save the picture.
FU>
FU> I am sure, there are some controls already made.
FU> I am thankful for any comment on that !
FU> Best regards
FU> Frank Uray
 
Z

zacks

Hi all

I need to do a image viewer, just to view and zoom pictures
in jpeg. I do not need to edit or save the picture.

I am sure, there are some controls already made.
I am thankful for any comment on that !

I would recommend doing research into the System.Drawing Image Class:

http://msdn2.microsoft.com/en-us/library/system.drawing.image.aspx

And into the System.Windows.Forms PictureBox control:

http://msdn2.microsoft.com/en-us/library/system.windows.forms.picturebox.aspx

The PictureBox control has an Image property that works exactly like
the Image Class. Pay particular attention to the PictureBox SizeMode
property.

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.
 
Z

zacks

I would recommend doing research into the System.Drawing Image Class:

http://msdn2.microsoft.com/en-us/library/system.drawing.image.aspx

And into the System.Windows.Forms PictureBox control:

http://msdn2.microsoft.com/en-us/library/system.windows.forms.picture...

The PictureBox control has an Image property that works exactly like
the Image Class. Pay particular attention to the PictureBox SizeMode
property.

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.

Let me add something. One of the valid values for the
PictureBox.SizeMode property is Zoom which will make images larger on
the screen, but only within the confines of the picturebox control
that contains the image. If you want to magnify it more, you will need
to do the technique I mentioned earlier.

The difference between SizeMode Zoom and SizeMode Stretch is that Zoom
maintains the image's aspect ratio, Stretch does not.
 
P

Peter Duniho

[...]
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.DrawImage()
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top