Devision in c# not going the way i expect

Posted by Younes on Stack Overflow See other posts from Stack Overflow or by Younes
Published on 2010-03-08T11:04:42Z Indexed on 2010/03/08 11:06 UTC
Read the original article Hit count: 311

Filed under:
|

Im trying to write something to get my images to show correctly. I have 2 numbers "breedtePlaatje" and "hoogtePlaatje". When i load those 2 vars with the values i get back "800" and "500" i expect "verH" to be (500 / 800) = 0,625. Tho the value of verH = 0..

This is the code:

                        int breedtePlaatje = Convert.ToInt32(imagefield.Width);
                        int hoogtePlaatje = Convert.ToInt32(imagefield.Height);

                        //Uitgaan van breedte plaatje
                        if (breedtePlaatje > hoogtePlaatje)
                        {
                            double verH = (hoogtePlaatje/breedtePlaatje);
                            int vHeight = Convert.ToInt32(verH * 239);

                            mOptsMedium.Height = vHeight;
                            mOptsMedium.Width = 239;

                            //Hij wordt te klein en je krijgt randen te zien, dus plaatje zelf instellen
                            if (hoogtePlaatje < 179)
                            {
                                mOptsMedium.Height = 179;
                                mOptsMedium.Width = 239;
                            }
                        }

Any tips regarding my approach would be lovely aswell.

© Stack Overflow or respective owner

Related posts about c#

Related posts about scale