English Metric Units and Open XML

English Metric Units and Open XML

在Open XML里使用了English Metric Units(EMUs)来做为度量单位。好比this

public class Extent : OpenXmlLeafElement的cx和cy属性

<wp:extent cx="1828800" cy="1828800"/>

MSDN的解释:The cx attributes specifies that this object has a height of 1828800 EMUs (English Metric Units),并没给出具体的解释。code

wikipedia里关于Office_Open_Xml里关于DrawingML里面对EMUs有一段定义orm

http://en.wikipedia.org/wiki/Office_Open_XML_file_formats#DrawingMLxml

A DrawingML graphic's dimensions are specified in English Metric Units (EMUs). It is so called because it allows an exact common representation of dimensions originally in either English or Metric units. This unit is defined as 1/360,000 of a centimeter and thus there are 914,400 EMUs per inch, and 12,700 EMUs per point.

1EMUs= 1/914400英寸图片

而咱们在计算的时候,一般获得的是图片的像素,根据图片分辨率的不一样,每一寸上的像素点事不一样的。
因此 EMUS=像素*1914400/分辨率ip

代码以下ci

Bitmap bm = new Bitmap("image.jpg");
DocumentFormat.OpenXml.Drawing.Extents extents = new DocumentFormat.OpenXml.Drawing.Extents();
extents.Cx = (long)bm.Width * (long)((float)914400 / bm.HorizontalResolution);
extents.Cy = (long)bm.Height * (long)((float)914400 / bm.VerticalResolution);
相关文章
相关标签/搜索