本文介绍了GUI开发人员如何处理可变的像素密度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如今,显示器的尺寸和分辨率范围非常大.例如,我的34.5厘米×19.5厘米显示屏(对角线为39.6厘米或15.6英寸)的像素为1366×768像素,而对角线为15英寸的MacBook Pro(第三代)的像素为2880×1800像素.

Todays displays have a quite huge range in size and resolution. For example, my 34.5cm × 19.5cm display (resulting in a diagonal of 39.6cm or 15.6") has 1366 × 768 pixels, whereas the MacBook Pro (3rd generation) with a 15" diagonal has 2880×1800 pixels.

许多人抱怨使用如此高分辨率的显示器,一切都太小了(请参阅示例).这很容易解释开发人员何时使用像素定义其GUI.对于传统显示器"来说,这不是一个大问题,因为大多数显示器上的像素大小可能大致相同.但是在像素密度更高的新型显示器上,像素就更小了.

Multiple people complained that everything is too small with such high resolution displays (see example). That is simple to explain when developers use pixels to define their GUI. For "traditional displays", this is not a big problem as the pixels might have about the same size on most monitors. But on the new monitors with much higher pixel density the pixels are simply smaller.

那么用户界面开发人员应该/应该如何处理该问题?是否可以获取屏幕的物理尺寸?是否可以设置物理尺寸而不是基于像素的尺寸?还是一个问题(自上次阅读以来已经有一段时间了)还是在此同时解决?

So how can / should user interface developers deal with that problem? Is it possible to get the physical size of the screen? Is it possible to set physical sizes instead of pixel-based ones? Is that still a problem (it's been a while since I last read about it) or was that fixed meanwhile?

(当我尝试 css似乎支持cm .w3schools.com/cssref/tryit.asp?filename = trycss_unit_cm>此处,它不是设置的大小).

(While css seems to support cm, when I try here it, it is not the set size).

推荐答案

使用支持分辨率独立性的工具包或框架. WPF 是从头开始构建的,与分辨率无关.甚至像 Windows窗体之类的旧框架也可以学习新技巧. OSX/iOS Windows (或浏览器(如果我们在谈论网络)本身可能会尝试以通过自动缩放来解决该问题,但是如果涉及位图图形,则开发人员可能需要提供不同的位图(如Android)(与其他操作系统相比,它们面临的分辨率和密度变化最大)

Use a toolkit or framework that support resolution independence. WPF is built from the ground up to be resolution-independent, but even old framework like Windows Forms can learn new tricks. OSX/iOS and Windows (or browser if we're talking about web) itself may try to take care the problem by automatic scaling, but if there's bitmap graphic involved, developers might need to provide different bitmaps such in Android (which face most varying resolution and densities compared to other OS)

,开发人员不必理会.开发人员应该只在乎设备的类别(例如,平板电脑和智能手机的UI不同),或者在乎DPI来决定要使用哪个位图资源.向量资源和字体应根据框架进行缩放.

No, and developers shouldn't care about it. Developers should only care about the class of the device (say, different UI for tablet and smartphone), and perhaps the DPI to decide which bitmap resource to use. Vector resource and font should be scaled by the framework.

取决于您上次阅读它的时间.即使对内部应用程序本身以及使用WPF或 UWP 轻松一点,不要期望主要的第三方应用程序很快就会加入. OSX 显示缩放效果似乎更好一些,而现代移动操作系统要么在有限的分辨率范围(iOS和Windows Phone)上运行,要么可以很好地处理所有可以想象得到的分辨率( Android )

Depend on when you last read about it. Windows support is still spotty, even for the internal apps itself, and while anyone developing in WPF or UWP have it easy, don't expect major third party apps to join soon. OSX display scaling seems to work a bit better, while modern mobile OS are either running on limited range of resolution (iOS and Windows Phone) or handle every resolution imaginable quite nicely (Android)

这篇关于GUI开发人员如何处理可变的像素密度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 07:00