C# newbie problem with variable types

Posted by ile on Stack Overflow See other posts from Stack Overflow or by ile
Published on 2010-03-26T15:22:34Z Indexed on 2010/03/26 15:23 UTC
Read the original article Hit count: 129

Filed under:
|
|
|
                    int newWidth = 100;
                    int newHeight = 100;
                    double ratio = 0;

                    if (img1.Width > img1.Height)
                    {
                        ratio = img1.Width / img1.Height;
                        newHeight = (int)(newHeight / ratio);
                    }
                    else
                    {
                        ratio = img1.Height / img1.Width;
                        newWidth = (int)(newWidth / ratio);
                    }


                    Image bmp1 = img1.GetThumbnailImage(newWidth, newHeight, null, IntPtr.Zero);
                    bmp1.Save(Server.MapPath("~/Uploads/Photos/Thumbnails/") + photo.PhotoID + ".jpg");

I always get Image with both height and width having same values (100)
I am obiously doing something wrong with type conversion?

© Stack Overflow or respective owner

Related posts about c#

Related posts about integer