English Metric Units and Open XML

English Metric Units and Open XML

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

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),并没给出具体的解释。

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

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

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/分辨率

代码如下

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);
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值