RasterImageSetResolution Method |
Namespace: Aspose.Imaging
[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; // Get horizontal and vertical resolution of the 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) { // Use the SetResolution method for updating both resolution values in a single call. 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); } // The output may look like this: // The horizontal resolution, in pixels per inch: 300 // The vertical resolution, in pixels per inch: 300 // Set resolution values to 96 dpi // The horizontal resolution, in pixels per inch: 96 // The vertical resolution, in pixels per inch: 96 }