HorizontalResolution
RasterImage.HorizontalResolution property
获取或设置此图像的水平分辨率,以每英寸像素为单位RasterImage
.
public virtual double HorizontalResolution { get; set; }
适当的价值
水平分辨率。
评论
请注意,默认情况下,此值始终为 96,因为不同的平台无法返回屏幕分辨率。您可以考虑使用 SetResolution 方法在一次调用中更新两个分辨率值。
例子
以下示例显示了如何设置光栅图像的水平/垂直分辨率。
[C#]
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.jpg"))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
// 获取图像的水平和垂直分辨率
double horizontalResolution = rasterImage.HorizontalResolution;
double verticalResolution = rasterImage.VerticalResolution;
System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", horizontalResolution);
System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", verticalResolution);
if (horizontalResolution != 96.0 || verticalResolution != 96.0)
{
// 使用 SetResolution 方法在一次调用中更新两个分辨率值。
System.Console.WriteLine("Set resolution values to 96 dpi");
rasterImage.SetResolution(96.0, 96.0);
System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", rasterImage.HorizontalResolution);
System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", rasterImage.VerticalResolution);
}
// 输出可能如下所示:
// 水平分辨率,以每英寸像素为单位:300
// 垂直分辨率,以每英寸像素为单位:300
// 将分辨率值设置为 96 dpi
// 水平分辨率,以每英寸像素为单位:96
// 垂直分辨率,以每英寸像素为单位:96
}
也可以看看
- class RasterImage
- 命名空间 Aspose.Imaging
- 部件 Aspose.Imaging