public static void Run() { Console.WriteLine("Running example AdjustContrast"); // To get proper output please apply a valid Aspose.Imaging License. You can purchase full license or get 30 day temporary license from http:// Www.aspose.com/purchase/default.aspx."); // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages(); // Load an image in an instance of Image using (Image image = Image.Load(dataDir + "aspose-logo.jpg")) { // Cast object of Image to RasterImage RasterImage rasterImage = (RasterImage)image; // Check if RasterImage is cached and Cache RasterImage for better performance if (!rasterImage.IsCached) { rasterImage.CacheData(); } // Adjust the contrast rasterImage.AdjustContrast(10); // Create an instance of TiffOptions for the resultant image, Set various properties for the object of TiffOptions and Save the resultant image to TIFF format TiffOptions tiffOptions = new TiffOptions(TiffExpectedFormat.Default); tiffOptions.BitsPerSample = new ushort[] { 8, 8, 8 }; tiffOptions.Photometric = TiffPhotometrics.Rgb; rasterImage.Save(dataDir + "AdjustContrast_out.tiff", tiffOptions); } Console.WriteLine("Finished example AdjustContrast"); }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_PSD(); //ExStart:AdjustingContrast String sourceFile = dataDir + @"sample.psd"; string destName = dataDir + @"AdjustContrast_out.tiff"; // Load an existing image into an instance of RasterImage class using (var image = Image.Load(sourceFile)) { // Cast object of Image to RasterImage RasterImage rasterImage = (RasterImage)image; // Check if RasterImage is cached and Cache RasterImage for better performance if (!rasterImage.IsCached) { rasterImage.CacheData(); } // Adjust the contrast rasterImage.AdjustContrast(50); // Create an instance of TiffOptions for the resultant image, Set various properties for the object of TiffOptions and Save the resultant image to TIFF format TiffOptions tiffOptions = new TiffOptions(TiffExpectedFormat.Default); tiffOptions.BitsPerSample = new ushort[] { 8, 8, 8 }; tiffOptions.Photometric = TiffPhotometrics.Rgb; rasterImage.Save(destName, tiffOptions); } //ExEnd:AdjustingContrast }