Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have 4 images that are of decreasing size down the screen. The composition of these images and their relation to each other must appear the same on all possible screen resolutions, with specific regards to their size, and their margins. In other words, the height, width and margins must all be factors of the height and width of the screen. What is the generic formula if the only known values are the height and width of the screen?
Posted
Comments
Wayne Gaylard 31-Mar-11 2:52am    
It would help if you stated what type of project are you working on (WPF or Winforms) as the solution would be quite different for either. You should also tell us what controls you are using to display the images.

If you want to physically resize the image, you may want to use a library like this[^]. Else you'll need to add controls to your form which support resizing the image depending on your needs.

Eduard
 
Share this answer
 
The Silverlight2 app has 4 images in a grid on the page. I need to set the height, width and margins for each image. These values cannot be constants, because then they will not be displayed correctly for the various possible screen resolutions. These properties should get their values from calculations using only the resolution of the screen. The composite look and feel of these images should be the same regardless of the resolution.
The images are all square, right-aligned and top-aligned, so I only need to set the margins from the top and right (left and bottom margins = 0), and use a single value for height and width.
I use the following to get the resolution:
string Width = Convert.ToString(HtmlPage.Window.Eval("screen.width"));
string Height = Convert.ToString(HtmlPage.Window.Eval("screen.height"));
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900