|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
dealing with images of varing sizes on a form.Hi,
I have an application that allows a user to select a jpg/gif file and display them in a picture box. The issue is that the pictures are of course different sizes, and therefore they need to be resized some how to fit the space the picturebox uses on the form. Setting the picture boxs size mode to stretch just makes the picture look silly, and users don't like it. There is not an option like best fit which would scale the picture, but keep its org perspective.... Whats the best way to deal with this ???? Thanks I use the routine below to size my image to a maximum size that fits in the
picture box yet retains the proportions. Note that MxSz is the original size of the picture box. After the call to this routine, the image and picure box can be resized to the returned size. Public Function get_NewImgSize(ByVal OldImage As Image, ByVal MxSz As Size) As Size Dim w As Integer = OldImage.Width Dim h As Integer = OldImage.Height Dim nw, nh As Integer Dim pctw As Double = MxSz.Width / w Dim pcth As Double = MxSz.Height / h Dim wtoh As Double = w / h If pctw < pcth Then nw = CInt(pctw * w) nh = CInt(pctw * h) Else nw = CInt(pcth * w) nh = CInt(pcth * h) End If Return New Size(nw, nh) End Function -- Show quoteHide quoteDennis in Houston "Aussie Rules" wrote: > Hi, > > I have an application that allows a user to select a jpg/gif file and > display them in a picture box. > > The issue is that the pictures are of course different sizes, and therefore > they need to be resized some how to fit the space the picturebox uses on the > form. > > Setting the picture boxs size mode to stretch just makes the picture look > silly, and users don't like it. There is not an option like best fit which > would scale the picture, but keep its org perspective.... > > Whats the best way to deal with this ???? > > Thanks > > > Hi Aussie,
>Whats the best way to deal with this ???? I also found some articles about resizing image in .NET, wish it helps:Resizing a Photographic image with GDI+ for .NET http://www.codeproject.com/csharp/imageresize.asp Image Processing for Dummies with C# and GDI+ Part 4 - Bilinear Filters and Resizing http://www.codeproject.com/cs/media/imageprocessing4.asp Thanks! Best regards, Gary Chang Microsoft Community Support ====================================================== PLEASE NOTE the newsgroup SECURE CODE and PASSWORD will be updated at 9:00 AM PST, February 14, 2006. Please complete a re-registration process by entering the secure code mmpng06 when prompted. Once you have entered the secure code mmpng06, you will be able to update your profile and access the partner newsgroups. ====================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from this issue. ====================================================== This posting is provided "AS IS" with no warranties, and confers no rights. ====================================================== |
|||||||||||||||||||||||