zoukankan      html  css  js  c++  java
  • 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);
  • 相关阅读:
    Jenkins安装后,安装插件失败。报错SunCertPathBuilderException
    计算机网络
    abaqus
    品优购
    html5 css3
    css定位
    元素的显示与隐藏 / 精灵图
    学成在线案例
    css(3)
    css(2)
  • 原文地址:https://www.cnblogs.com/ac1985482/p/4097666.html
Copyright © 2011-2022 走看看