c# - Finding a percentage -


here's problem. have picture have different height every time according picture that's loaded.

i'd scale picture fits inside of document has 800 pixels height. if image has 2560px in height, need find out percentage needed bring pixel height down 750 fits snuggly on page.

i'm stuck trying find formula simple enough problem.

here's code:

itextsharp.text.image pic = itextsharp.text.image.getinstance(     image, system.drawing.imaging.imageformat.jpeg);  if (pic.height > pic.width) {     //maximum height 800 pixels.     pic.height formula goes here.... } else {     //maximum width 600 pixels.     pic.width formula goes here.... } 

some number p such p * 2560 = 750. therefore, p = 750 / 2560 = 0.29296875.

of course, make sure floating-point division.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -