从C#中的像素计算英寸和厘米 [英] Calculate inches and centimeters from pixels in C#

查看:468
本文介绍了从C#中的像素计算英寸和厘米的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用生产力"应用程序,因此需要能够计算(以C#表示)英寸和厘米.显然,基于像素.

I am working on a Productivity app and need to be able to calculate (in C#) inches and centimeters. Based on pixels, obviously.

当您打开Microsoft Word并搜索模板时,您会发现例如名片.您会看到它们的测量结果基于英寸和/或厘米.当他们仅处理屏幕上的像素时,如何获得这些计算结果?

When you open Microsoft Word, and search through the Templates, you'll find, for example, business cards. And you'll see that their measurements are based upon inches and/or centimeters. How do they get those calculations when they're dealing only with pixels on a screen?

人们通常会说等等,你不能那样做,等等",但这完全不是事实.我打印了一张名片样本,MS Word说大约是8"x4".在屏幕上,它并不大,但是当它被打印到纸上时,它的含义恰恰是它的意思.这样就可以做到,而且我不想听到别人说你不能那样做".

People generally say "blah blah you can't do that blah blah blah" but that's not true at all. I printed a sample business card, MS Word said it would be about 8"x4". On the screen it was not that big but when it was printed onto paper it was exactly what it said. So it can be done and I don't want to hear another person say "You cannot do that".

推荐答案

我认为像素到厘米的转换取决于显示图像的媒体的 DPI(每英寸点数).

I think the conversion of pixels to centimeters depends on the DPI (dots per inch) of the media which is displaying the image.

该公式也很容易转换,即

Also the formula is simple for conversion ie,

points = pixels * 72 / 96

因为存在每英寸72个和每英寸96像素(可以假设)

since there 72 points per inch and 96 pixels per inch(you can assume)

您还可以检查如何将像素转换为厘米?

实际上,您不会将像素转换为cm.还有一点 所需的信息,而又不确切知道它是什么 您想要做的事情,很难完全解决这个问题.有一个 300 DPI/PPI的实际印刷规范(即300/2.54 像素/厘米).

In truth, you don't convert pixels to cm. There is a little more information that is needed and without knowing exactly what it is that you want to do, it is difficult to address this completely. There is a de facto norm of 300 DPI /PPI for printing (that is 300 / 2.54 pixels/cm).

像素是计算机屏幕上的彩色点之一, 同时显示图片和文字(以及之间的所有空白区域 他们).大多数计算机屏幕每英寸显示72或96像素. 大多数打印基于每英寸300像素(很少使用240 PPI).

A pixel is one of the colored dots on your computer screen that makes up both images and text (as well as all of the blank areas in between them). Most computer screens display either 72 or 96 pixels per inch. Most printing is based on 300 pixels per inch (rarely 240 PPI).

如果您要打印:如果您要制作4 x 6英寸 在300 DPI(每英寸点数)打印机上打印,您需要将文件 包含1200 x 1800像素. 8 x10的打印输出必须为2400 x 3000像素.实际上,大多数消费者打印系统将处理 此转换适合您.您只需要告诉软件打印什么尺寸 您要使软件将图像调整大小"为正确的大小 尺寸.

If you are asking about printing: If you want to make a 4 x 6 inch print on a 300 DPI (Dot Per Inch) printer you need your file to contain 1200 x 1800 pixels. An 8 x10 printout will have to be 2400 x 3000 pixels. In reality, most consumer printing systems will handle this conversion for you. You just tell the software what size print you want to make the software will "re size" your image to the correct dimensions.

这篇关于从C#中的像素计算英寸和厘米的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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