[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.1

problem with image resize function

Asked by vthunder70 in Programming for ASP.NET, .NET Framework 2.x

Hi guys,

I have a function in my asp.net 2.0 that is not working properly. I wish I could take credit for this function, but I put together through a bunch of tutorials and my last problem is the size issue.
I cannot get the size to be proportional.

I will like to make it so that if i want a square(w200px h200px) or rectangule(w200px h250px) to scale down proportionally.

I've been at it for a long time and I'm going crazy :(

Thanks so much!
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
the function
=============
Public Function ProportionallyResizeBitmap(ByVal src As Bitmap, ByVal maxWidth As Integer, ByVal maxHeight As Integer) As Bitmap
        Dim w As Integer = src.Width
        Dim h As Integer = src.Height
        Dim longestDimension As Integer = IIf((w < h), w, h)
        Dim shortestDimension As Integer = IIf((w > h), w, h)
        Dim factor As Single = CSng(longestDimension) / shortestDimension
        Dim newWidth As Double = maxWidth
        Dim newHeight As Double = maxWidth / factor
        If w < h Then
            newWidth = maxHeight / factor
            newHeight = maxHeight
        End If
        Dim result As New Bitmap(CInt(newWidth), CInt(newHeight))
        Using g As Graphics = Graphics.FromImage(DirectCast(result, System.Drawing.Image))
            g.DrawImage(src, 0, 0, CInt(newWidth), CInt(newHeight))
        End Using
        Return result
    End Function
 
===========
how I call the function to upload and copy it to its destination
===========
If FileUpload1.FileName <> "" Then
 
            'thubnail creation and upload
            Dim fileName As String = FileUpload1.FileName
            Dim src As Bitmap = TryCast(Bitmap.FromStream(FileUpload1.PostedFile.InputStream), Bitmap)
            Dim resultThumb As Bitmap = ProportionallyResizeBitmap(src, 200, 200)
            Dim saveName As String = Server.MapPath(savePath) + fileName
            resultThumb.Save(saveName, ImageFormat.Jpeg)
[+][-]02/05/09 08:26 AM, ID: 23560942Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Programming for ASP.NET, .NET Framework 2.x
Sign Up Now!
Solution Provided By: rdogmartin
Participating Experts: 2
Solution Grade: A
 
[+][-]02/04/09 08:20 PM, ID: 23556441Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/04/09 08:26 PM, ID: 23556465Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/05/09 07:52 AM, ID: 23560525Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/05/09 10:08 AM, ID: 23562203Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/06/09 04:21 PM, ID: 23575670Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/06/09 05:03 PM, ID: 23575890Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/11/09 06:51 PM, ID: 23618756Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091118-EE-VQP-93 - Hierarchy / EE_QW_3_20080625