通过屏幕分辨率计算图像的公式? [英] Formula for images by screen resolution?

查看:99
本文介绍了通过屏幕分辨率计算图像的公式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有4张图像在屏幕下方逐渐缩小.这些图像的组成及其相互之间的关系在所有可能的屏幕分辨率上都必须看起来相同,并且要特别注意其大小和边距.换句话说,高度,宽度和边距都必须是屏幕高度和宽度的因素.如果唯一已知的值是屏幕的高度和宽度,那么通用公式是什么?

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?

推荐答案

如果您要实际调整图像的大小,则可能需要使用像 [
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


Silverlight2应用程序在页面上的网格中有4张图像.我需要为每个图像设置高度,宽度和边距.这些值不能为常数,因为对于各种可能的屏幕分辨率,它们将无法正确显示.这些属性应仅使用屏幕分辨率从计算中获取其值.无论分辨率如何,这些图像的合成外观应相同.
图像都是正方形的,右对齐的和顶部对齐的,因此我只需要设置顶部和右侧的边距(左侧和底部的边距= 0),并对高度和宽度使用单个值.
我使用以下方法来获得分辨率:
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"));


这篇关于通过屏幕分辨率计算图像的公式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆