2025-11-16 19:33:43 +08:00

28 lines
759 B
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace XPrint.Production.Business.Tools
{
public static class ImageTool
{
/// <summary>
/// 根据dpi毫米转像素
/// </summary>
/// <param name="mm">毫米值</param>
/// <param name="dpi"> 每英寸点数打印设备常用300DPI</param>
/// <returns>对应的像素值</returns>
public static float MMToPxWithDpi(float mm, float dpi)
{
if (mm <= 0 || dpi <= 0)
{
return 0;
}
// 1英寸 = 25.4毫米所以1毫米 = dpi/25.4像素
return mm * (dpi / 25.4f);
}
}
}