C1Preview 毫米值转换为打印机像素值

        /// <summary>
        /// 转换单位(每英寸的毫米值)
        /// </summary>
        private const double MMPerInch = 25.4;
        /// <summary>
        /// 每百分之一inch=0.254mm
        /// </summary>
        private const float mmppi = 0.254f;
        /// <summary>
        /// 每mm=pipmm百分之一inch
        /// </summary>
        private const float pipmm = 3.937f;       

        /// <summary>
        /// 毫米值转换为打印机像素值
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        private int ConvertMMToPixel(double value)
        {
            int rt = (int)Math.Round(value * pipmm * horizontalDPI / 100, 0);
            return rt;
        }
        /// <summary>
        /// 毫米值转换为打印机像素值,返回值为float型
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        private float ConvertMMToPixel_F(double value)
        {
            float rt = (float)Math.Round(value * pipmm * horizontalDPI / 100, 5);
            return rt;
        }

 

posted on 2013-12-31 14:52  读懂洋字码  阅读(647)  评论(0编辑  收藏  举报