dpi

Reliable way to check if image is Grey scale

為{幸葍}努か 提交于 2020-01-24 04:27:07
问题 I am currently working on one use case where i need to determine if uploaded image is Grey Scale or RGB. I found couple of ways to identify this, but not sure if they are reliable and can be used collectively to confirm image is grey scale or not. Part 1: Read Image and get NumberDataElements using Raster. BufferedImage image = ImageIO.read(file); Raster ras = image.getRaster(); int elem = ras.getNumDataElements(); I observed value of elem is "1" in some cases, but not in all. Part 2: Check

C# code to get maximum dpi of installed or selected printer

醉酒当歌 提交于 2020-01-23 13:29:11
问题 I want to get Maximum Dpi of installed or selected printer. I tried PrinterSettings ps = new PrinterSettings(); MessageBox.Show(ps.PrinterResolutions.ToString()); and I get this output: System.Drawing.Printing.PrinterSettings+PreinterResolutionCollection (The desired output is 600x600). 回答1: Using LINQ: PrinterSettings ps = new PrinterSettings(); var maxResolution = ps.PrinterResolutions.OfType<PrinterResolution>() .OrderByDescending(r => r.X) .ThenByDescending(r => r.Y) .First(); MessageBox

android——屏幕适配

拈花ヽ惹草 提交于 2020-01-23 13:19:08
一,基本概念 1:dip: 其实也就是dp,与像素无关 2:px: 像素,在安卓布局中不用px,因为每个手机像素不同,px显示的布局大小也就不同 3:dpi: 通俗点就是每英寸多少个像素,简称像素密度,常见值120,160,240, 4:density: 密度,常见值1.5,1.0,如果密度等于1,那么,1dp=1px。density的值是可以直接得到的,如下: final float scale = context.getResources().getDisplayMetrics().density; 5:分辨率: 横纵方向的像素点的数量,例如:1280 X 800, 6:屏幕尺寸: 屏幕对角线的长度,常见有4.7,5.5 二,应用 android里density和dpi 都是可以直接获取的: final float density= context.getResources().getDisplayMetrics().density; final float densityDpi= context.getResources().getDisplayMetrics().densityDpi; 其实:density = dpi/(160像素/英寸) 三,各种单位换算 1. 计算dpi    比如一个机器,屏幕4寸,分辨率480X800,他的dpi能算么。   因为不知道边长

How do you scale the title bar on a DPI aware win application?

天涯浪子 提交于 2020-01-20 16:57:26
问题 I am making my app dpi-aware per monitor by setting <dpiAware>True/PM</dpiAware> in the manifest file. I can verify with process explorer that this is indeed working or by calling GetProcessDpiAwareness. This is all working fine and I can scale anything in the client area fine in my code. However, my only problem is that if I drag my app from a system-dpi monitor to a non-system dpi monitor, the title bar and any system menu would either become too big or too small. This isn't the case for

Android屏幕适配

空扰寡人 提交于 2020-01-19 03:25:17
单位 1、px:像素,是绘图的基本元素,屏幕上的点 2、dp/dip:设备独立像素,不依赖于设备长度不变 x /dip=dpi/160 所以 dip 类似于英寸、长度(dp=dip,sp类似于dip) dip=160*inch dip= 160/dpi * px 当dip一定时,dpi 越大,px就越大 3、dpi:density 像素密度,每英寸的像素点 4、sp:放大像素,主要用于字体显示 5、inch:长度(真实长度)英寸 6、广义分辨率=长px*宽px 转化 重要转换公式:px = dp x dpi (1)首先转化到同一密度 (2)再按画面比例计算出来 屏幕尺寸、密度获取 DisplayMetrics metric = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metric); int width = metric.widthPixels; // 屏幕宽度(像素) int height = metric.heightPixels; // 屏幕高度(像素) float density = metric.density; // 屏幕密度(0.75 / 1.0 / 1.5) int densityDpi = metric.densityDpi; // 屏幕密度DPI(120 /

delphi 设置win10 dpi 缩放规则

半腔热情 提交于 2020-01-17 21:50:44
一、dpi介绍 dpi是“Dots Per Inch”的缩写,表示每英寸的像素点个数,也就是像素点的密集度。 dpi = 总像素点 / 总面积 比如一个32寸的显示,但分辨率只有1920*1440,而一个24寸的显示器,分辨率却达到3840*2160,很明显后面这个显示器的每英寸的像素点的个数多,显示的画面更加细腻。 所以:高分辨率不等于高dpi。 苹果的视网膜屏幕的核心就是高dpi:屏幕面积小,却分辨率高达5k,每英寸的像素点(dpi)固然多,画面自然细腻。 二、高dpi显示器如何导致软件显示异常 随着2K、4K显示器的普及,在使用这些高dpi显示器时,为了保证系统软件界面看起来不至于太小,导致视觉疲劳,一般会在系统中设置缩放比例。Windows操作系统对高dpi显示器缩放支持最好的是windows 10,建议使用高dpi显示器时使用Windows 10操作系统。 假设现在有一个软件界面(宽为950像素,高为700像素),该软件在24寸、分辨率为1900*1400的显示器上显示正常,但放到高dpi显示器(同样是24寸,但分辨率为3800*2800)上显示效果会如何? 从上图可以看到,同样尺寸的软件界面,在高dpi显示器上会显得非常小,会造成严重的视觉疲劳。 所以我们的软件需要针对高dpi进行缩放。 三、Windows 10 DPI缩放规则 Windows

Printing a panel to a printer

ⅰ亾dé卋堺 提交于 2020-01-17 04:51:19
问题 I am trying to print a panel (with its contents) to a printer. I saw different posts on the net, but I am not able to print the panel and get the correct size. The panel is getting printed very large and not as expected. For example, I want to print a panel and get as output size 80mm X 40mm: private void Print_Click(object sender, EventArgs e) { int pixelsWidth = 300; // 300 pixels= ~8cm int pixelsHeight = 150; // 150 pixels= ~4cm panelLabel.Size = new Size(pixelsWidth,pixelsHeight);

html模板打印

泪湿孤枕 提交于 2020-01-16 13:48:33
DPI: 每英寸的像素点 打印机里的DPI (Dot Per Inch )是指打印分辨率,指的是打印机在每英寸可打印的点数。 /* css 可控制打印时的样式 */ @Media print{ } / * @page 打印文档时修改 margin,orphans,widow 和 page breaks of the document(分页符)。 */ /* @page :first 伪类选择器 描述的是:打印文档的时候,第一页的样式。*/ @page{ } 参考资料: 1、 @page 2、 orphans 3、widows属性是当页面要执行打印操作时的一个样式,表示当页面内部要分页的时候必须在页面顶部保留的最少行数,例如定义widows:2;就表示在页面顶部保留2行。 来源: CSDN 作者: CherryCola_zjl 链接: https://blog.csdn.net/CherryCola_zjl/article/details/103999566

DPI not scaling properly

风格不统一 提交于 2020-01-14 13:29:56
问题 I created a custom UserControl that functions much like a numbericUpDown but with various enhancements. For example, it can display fractions. However, this control does not scale as well as some of my other controls on my form, forcing my UI to look awkward. I played around with the AutoScaleMode of both the control and it's parent control. Nothing seems to work, though setting the AutoScaleMode to None seems to have less impact than the other settings. I also tried manually to lessen the

When printing an image, what determines how large it will appear on a page?

微笑、不失礼 提交于 2020-01-13 03:23:26
问题 Using Python's Imaging Library I want to create a PNG file. I would like it if when printing this image, without any scaling, it would always print at a known and consistent 'size' on the printed page. Is the resolution encoded in the image? If so, how do I specify it? And even if it is, does this have any relevance when it goes to the printer? 回答1: As of PIL 1.1.5, there is a way to get the DPI: im = ... # get image into PIL image instance dpi = im.info["dpi"] # retrive the DPI print dpi #