Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Drawing / June 2006

Tip: Looking for answers? Try searching our database.

scaling an image in a picturebox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lee Crabtree - 25 Apr 2006 20:30 GMT
I have a PictureBox control on a form that displays a bitmap.  However,
the bitmap rarely matches the size of the PictureBox.  The different
SizeMode properties don't really do it for me.  In one case, it changes
the size of the PictureBox itself, making it larger than the form.  In
another, it scales the image to the wrong aspect ratio.

What's the best way to rescale this image at the proper aspect ration
inside this PictureBox?

Lee Crabtree
Bob Powell [MVP] - 26 Apr 2006 00:05 GMT
You cannot do this correctly with a PictureBox. The PictureBox is a
ridicuously easy control to replace however and it could be done based on my
article on how to display an image in it's original aspect ratio using a
transform.

See the GDI+ FAQ for details.

Signature

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.

>I have a PictureBox control on a form that displays a bitmap.  However, the
>bitmap rarely matches the size of the PictureBox.  The different SizeMode
[quoted text clipped - 6 lines]
>
> Lee Crabtree
Lee Crabtree - 26 Apr 2006 16:33 GMT
I've read your GDI+ FAQ in the past, and it was extremely useful.
Actually, the app I'm writing is a rewrite of one I wrote a while back
in which I bastardized a few of your techniques.  I'm trying to do it
more gracefully this time.

Lee Crabtree

> You cannot do this correctly with a PictureBox. The PictureBox is a
> ridicuously easy control to replace however and it could be done based on my
> article on how to display an image in it's original aspect ratio using a
> transform.
>
> See the GDI+ FAQ for details.
Ze Luis - 21 Jun 2006 11:27 GMT
> You cannot do this correctly with a PictureBox. The PictureBox is a
> ridicuously easy control to replace however and it could be done based on my
> article on how to display an image in it's original aspect ratio using a
> transform.
>
> See the GDI+ FAQ for details.

See the GDI+ FAQ for details.

Where are they (GDI+ FAQ)???

this links are wrong

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
Markus - 26 Apr 2006 06:35 GMT
> What's the best way to rescale this image at the proper aspect ration
> inside this PictureBox?

PictureBoxSizeMode.Zoom (keeps aspect ratio)

<http://msdn2.microsoft.com/de-de/library/system.windows.forms.pictureboxsizemode
(VS.80).aspx
>

Markus
Lee Crabtree - 26 Apr 2006 16:36 GMT
Strangely, Zoom isn't included in the enumeration as the docs suggest.

Lee Crabtree

>> What's the best way to rescale this image at the proper aspect ration
>> inside this PictureBox?
[quoted text clipped - 4 lines]
>
> Markus
Markus - 27 Apr 2006 06:18 GMT
> Strangely, Zoom isn't included in the enumeration as the docs
> suggest.
>
> Lee Crabtree

You need .NET Framework v2.0, it's not included in 1.1... sorry I didn't
know that, too.

Markus

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.