I need to have a control that I can place on a form that I can view an Image.
But here's the catch, I need to view the entire image (no matter the size)
in a 400x400 pixel object. Also, I need to be able to to enlarge and shrink
the image in the same viewable area. Is there any .Net object that does
something similar to this or do I need to enhance an existing object such as
the PictureBox?

thx...sonny

Re: Image control by Morten

Morten
Wed Jul 18 11:14:23 CDT 2007

On Wed, 18 Jul 2007 15:52:04 +0200, sonny <sonny@discussions.microsoft.com> wrote:

> I need to have a control that I can place on a form that I can view an Image.
> But here's the catch, I need to view the entire image (no matter the size)
> in a 400x400 pixel object. Also, I need to be able to to enlarge and shrink
> the image in the same viewable area. Is there any .Net object that does
> something similar to this or do I need to enhance an existing object such as
> the PictureBox?
>
> thx...sonny
>

The PictureBox is the only control that has part of the functionality you seek (having AutoSize), however, you might be better off creating your own UserControl. Autosizing an image to fit is not so difficult, and you have more control than using a PictureBox.

I would be surprised if there aren't any free UserControls on the net doing this, although I'm not aware of any.

--
Happy coding!
Morten Wennevik [C# MVP]

Re: Image control by sonny

sonny
Wed Jul 18 11:28:03 CDT 2007

> The PictureBox is the only control that has part of the functionality you
seek (having AutoSize), however, you might be better off creating your own
UserControl. Autosizing an image to fit is not so difficult, and you have
more control than using a PictureBox.
>
> I would be surprised if there aren't any free UserControls on the net doing this, although I'm not aware of any.

That's what I was figuring. I was hoping that maybe there was a new control
in 3.0 or something that I didn't find in 2.0.

Oh well, thanks.

Re: Image control by Bob

Bob
Thu Jul 26 16:18:36 CDT 2007

You may be inspired by the article on how to draw an image at a given
size while retaining the aspect ratio.

This is in the GDI+ FAQ.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





sonny wrote:
>> The PictureBox is the only control that has part of the functionality you
> seek (having AutoSize), however, you might be better off creating your own
> UserControl. Autosizing an image to fit is not so difficult, and you have
> more control than using a PictureBox.
>> I would be surprised if there aren't any free UserControls on the net doing this, although I'm not aware of any.
>
> That's what I was figuring. I was hoping that maybe there was a new control
> in 3.0 or something that I didn't find in 2.0.
>
> Oh well, thanks.

Re: Image control by sonny

sonny
Tue Jul 31 20:12:01 CDT 2007

Thanks Bob,

I haven't been working on the image control piece for a few days now. But
I'd like to thank you for your Zoom Image example. I used it in my proof of
concept application.

Is there another way of duplicating the viewing functionality of 'Windows
Picture and Fax Viewer' instead of using GDI+?

"Bob Powell [MVP]" wrote:

> You may be inspired by the article on how to draw an image at a given
> size while retaining the aspect ratio.
>
> This is in the GDI+ FAQ.
>
> --
> Bob Powell [MVP]
> Visual C#, System.Drawing
>
> Ramuseco Limited .NET consulting
> http://www.ramuseco.com
>
> Find great Windows Forms articles in Windows Forms Tips and Tricks
> http://www.bobpowell.net/tipstricks.htm
>
> Answer those GDI+ questions with the GDI+ FAQ
> http://www.bobpowell.net/faqmain.htm
>
> All new articles provide code in C# and VB.NET.
> Subscribe to the RSS feeds provided and never miss a new article.
>
>
>
>
>
> sonny wrote:
> >> The PictureBox is the only control that has part of the functionality you
> > seek (having AutoSize), however, you might be better off creating your own
> > UserControl. Autosizing an image to fit is not so difficult, and you have
> > more control than using a PictureBox.
> >> I would be surprised if there aren't any free UserControls on the net doing this, although I'm not aware of any.
> >
> > That's what I was figuring. I was hoping that maybe there was a new control
> > in 3.0 or something that I didn't find in 2.0.
> >
> > Oh well, thanks.
>