SetResolution
JpegImage.SetResolution method
为此设置分辨率RasterImage
.
public override void SetResolution(double dpiX, double dpiY)
范围 | 类型 | 描述 |
---|---|---|
dpiX | Double | 水平分辨率(以每英寸点数为单位)RasterImage . |
dpiY | Double | 垂直分辨率(以每英寸点数为单位)RasterImage . |
例子
以下示例显示如何设置 JPEG 图像的水平/垂直分辨率。
[C#]
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.jpg"))
{
Aspose.Imaging.FileFormats.Jpeg.JpegImage jpegImage = (Aspose.Imaging.FileFormats.Jpeg.JpegImage)image;
// 获取 BmpImage 的水平和垂直分辨率
double horizontalResolution = jpegImage.HorizontalResolution;
double verticalResolution = jpegImage.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");
jpegImage.SetResolution(96.0, 96.0);
System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", jpegImage.HorizontalResolution);
System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", jpegImage.VerticalResolution);
}
// 输出可能如下所示:
// 水平分辨率,以每英寸像素为单位:300
// 垂直分辨率,以每英寸像素为单位:300
// 将分辨率值设置为 96 dpi
// 水平分辨率,以每英寸像素为单位:96
// 垂直分辨率,以每英寸像素为单位:96
}
也可以看看
- class JpegImage
- 命名空间 Aspose.Imaging.FileFormats.Jpeg
- 部件 Aspose.Imaging