public static void Run()
        {
            // 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.");
            // ExStart:AdjustGamma
            // 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
                if (!rasterImage.IsCached)
                {
                    // Cache RasterImage for better performance
                    rasterImage.CacheData();
                }

                // Adjust the gamma
                rasterImage.AdjustGamma(2.2f, 2.2f, 2.2f);

                // Create an instance of TiffOptions for the resultant image
                TiffOptions tiffOptions = new TiffOptions(TiffExpectedFormat.Default);
                // Set various properties for the object of TiffOptions
                tiffOptions.BitsPerSample = new ushort[] { 8, 8, 8 };
                tiffOptions.Photometric   = TiffPhotometrics.Rgb;

                // Save the resultant image to TIFF format
                rasterImage.Save(dataDir + "AdjustGamma_out.tiff", tiffOptions);
            }
            // ExEnd:AdjustGamma
        }
Beispiel #2
0
        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
        }
        public static void Run()
        {
            // 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.");

            // ExStart:ExpandOrCropAnImage
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages();

            // Load an image in an instance of Image
            using (RasterImage rasterImage = (RasterImage)Image.Load(dataDir + "aspose-logo.jpg"))
            {
                // setting for image data to be cashed
                rasterImage.CacheData();

                // Create an instance of Rectangle class and define X,Y and Width, height of the rectangle.
                Rectangle destRect = new Rectangle()
                {
                    X = -200, Y = -200, Width = 300, Height = 300
                };

                // Save output image by passing output file name, image options and rectangle object.
                rasterImage.Save(dataDir + "Grayscaling_out.jpg", new JpegOptions(), destRect);
            }
            // ExEnd:ExpandOrCropAnImage
        }
        public static void Run()
        {
            //ExStart:CroppingByShifts
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_JPEG();

            Console.WriteLine("Running example CroppingByShifts");
            // Load an existing image into an instance of RasterImage class
            using (RasterImage rasterImage = (RasterImage)Image.Load(dataDir + "aspose-logo.jpg"))
            {
                // Before cropping, the image should be cached for better performance
                if (!rasterImage.IsCached)
                {
                    rasterImage.CacheData();
                }

                // Define shift values for all four sides
                int leftShift   = 10;
                int rightShift  = 10;
                int topShift    = 10;
                int bottomShift = 10;

                // Based on the shift values, apply the cropping on image Crop method will shift the image bounds toward the center of image and Save the results to disk
                rasterImage.Crop(leftShift, rightShift, topShift, bottomShift);
                rasterImage.Save(dataDir + "CroppingByShifts_out.jpg");
            }

            Console.WriteLine("Running example CroppingByShifts");
            //ExEnd:CroppingByShifts
        }
        public static void Run()
        {
            // 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.");

            // ExStart:RotatingImageOnSpecificAngle
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages();

            // Load an image to be rotated in an instance of RasterImage
            using (RasterImage image = (RasterImage)Image.Load(dataDir + "aspose-logo.jpg"))
            {
                // Before rotation, the image should be cached for better performance
                if (!image.IsCached)
                {
                    image.CacheData();
                }

                // Perform the rotation on 20 degree while keeping the image size proportional with red background color
                image.Rotate(20f, true, Color.Red);

                // Save the result to a new file
                image.Save(dataDir + "RotatingImageOnSpecificAngle_out.jpg");
            }

            // ExEnd:RotatingImageOnSpecificAngle
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_PSD();

            //ExStart:CroppingbyShifts

            string sourceFile = dataDir + @"sample.psd";
            string destName   = dataDir + @"CroppingByShifts_out.jpg";

            // Load an existing image into an instance of RasterImage class
            using (RasterImage rasterImage = (RasterImage)Image.Load(sourceFile))
            {
                // Before cropping, the image should be cached for better performance
                if (!rasterImage.IsCached)
                {
                    rasterImage.CacheData();
                }

                // Define shift values for all four sides
                int leftShift   = 10;
                int rightShift  = 10;
                int topShift    = 10;
                int bottomShift = 10;

                // Based on the shift values, apply the cropping on image Crop method will shift the image bounds toward the center of image and Save the results to disk
                rasterImage.Crop(leftShift, rightShift, topShift, bottomShift);
                rasterImage.Save(destName, new JpegOptions());
            }

            //ExEnd:CroppingbyShifts
        }
Beispiel #7
0
        public static void Run()
        {
            //ExStart:AdjustGamma
            // 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 gamma
                rasterImage.AdjustGamma(2.2f, 2.2f, 2.2f);

                // 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 + "AdjustGamma_out.tiff", tiffOptions);
            }
            //ExEnd:AdjustGamma
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_PSD();

            //ExStart:CroppingbyRectangle

            string sourceFile = dataDir + @"sample.psd";
            string destName   = dataDir + @"CroppingByRectangle_out.jpg";

            // Load an existing image into an instance of RasterImage class
            using (RasterImage rasterImage = (RasterImage)Image.Load(sourceFile))
            {
                if (!rasterImage.IsCached)
                {
                    rasterImage.CacheData();
                }

                // Create an instance of Rectangle class with desired size,
                //Perform the crop operation on object of Rectangle class and Save the results to disk
                Rectangle rectangle = new Rectangle(20, 20, 20, 20);

                rasterImage.Crop(rectangle);
                rasterImage.Save(destName, new JpegOptions());
            }

            //ExEnd:CroppingbyRectangle
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_PSD();

            //ExStart:RotatinganImageonaSpecificAngle

            String sourceFile = dataDir + @"sample.psd";
            string destName   = dataDir + @"RotatingImageOnSpecificAngle_out.jpg";

            // Load an image to be rotated in an instance of RasterImage
            using (RasterImage image = (RasterImage)Image.Load(sourceFile))
            {
                // Before rotation, the image should be cached for better performance
                if (!image.IsCached)
                {
                    image.CacheData();
                }
                // Perform the rotation on 20 degree while keeping the image size proportional with red background color and Save the result to a new file
                image.Rotate(20f, true, Color.Red);
                image.Save(destName, new JpegOptions());
            }

            //ExEnd:RotatinganImageonaSpecificAngle
        }
        public static void Run()
        {
            Console.WriteLine("Running example AdjustBrightness");
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages();

            // Load an image in an instance of Image
            using (Image image__1 = Image.Load(dataDir + Convert.ToString("aspose-logo.jpg")))
            {
                // Cast object of Image to RasterImage
                RasterImage rasterImage = (RasterImage)image__1;

                // Check if RasterImage is cached and Cache RasterImage for better performance
                if (!rasterImage.IsCached)
                {
                    rasterImage.CacheData();
                }

                // Adjust the brightness
                rasterImage.AdjustBrightness(70);

                // Create an instance of TiffOptions for the resultant image, Set various properties for the object of TiffOptions and Save the resultant image
                TiffOptions tiffOptions = new TiffOptions(TiffExpectedFormat.Default);
                tiffOptions.BitsPerSample = new ushort[] { 8, 8, 8 };
                tiffOptions.Photometric   = TiffPhotometrics.Rgb;
                rasterImage.Save(dataDir + Convert.ToString("AdjustBrightness_out.tiff"), tiffOptions);
            }

            Console.WriteLine("Finished example AdjustBrightness");
        }
        public static void Run()
        {
            // ExStart:ExpandOrCropAnImage
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages();

            // Load an image in an instance of Image and Setting for image data to be cashed
            using (RasterImage rasterImage = (RasterImage)Image.Load(dataDir + "aspose-logo.jpg"))
            {
                rasterImage.CacheData();
                // Create an instance of Rectangle class and define X,Y and Width, height of the rectangle, and Save output image
                Rectangle destRect = new Rectangle {
                    X = -200, Y = -200, Width = 300, Height = 300
                };
                rasterImage.Save(dataDir + "Grayscaling_out.jpg", new JpegOptions(), destRect);
            }
            // ExEnd:ExpandOrCropAnImage
        }
        public static void Run()
        {
            //ExStart:RotatingImageOnSpecificAngle
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages();

            // Load an image to be rotated in an instance of RasterImage
            using (RasterImage image = (RasterImage)Image.Load(dataDir + "aspose-logo.jpg"))
            {
                // Before rotation, the image should be cached for better performance
                if (!image.IsCached)
                {
                    image.CacheData();
                }
                // Perform the rotation on 20 degree while keeping the image size proportional with red background color and Save the result to a new file
                image.Rotate(20f, true, Color.Red);
                image.Save(dataDir + "RotatingImageOnSpecificAngle_out.jpg");
            }

            //ExEnd:RotatingImageOnSpecificAngle
        }
Beispiel #13
0
        public static void Run()
        {
            //ExStart:CroppingByRectangle
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_JPEG();

            // Load an existing image into an instance of RasterImage class
            using (RasterImage rasterImage = (RasterImage)Image.Load(dataDir + "aspose-logo.jpg"))
            {
                if (!rasterImage.IsCached)
                {
                    rasterImage.CacheData();
                }

                // Create an instance of Rectangle class with desired size, Perform the crop operation on object of Rectangle class and Save the results to disk
                Rectangle rectangle = new Rectangle(20, 20, 20, 20);
                rasterImage.Crop(rectangle);
                rasterImage.Save(dataDir + "CroppingByRectangle_out.jpg");
            }
            //ExEnd:CroppingByRectangle
        }
Beispiel #14
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_DrawingAndFormattingImages();

            //ExStart:ExpandandCropImages

            string sourceFile = dataDir + @"example1.psd";
            string destName   = dataDir + @"jpeg_out.jpg";

            // Load an image in an instance of Image and Setting for image data to be cashed
            using (RasterImage rasterImage = (RasterImage)Image.Load(sourceFile))
            {
                rasterImage.CacheData();
                // Create an instance of Rectangle class and define X,Y and Width, height of the rectangle, and Save output image
                Rectangle destRect = new Rectangle {
                    X = -200, Y = -200, Width = 300, Height = 300
                };
                rasterImage.Save(destName, new JpegOptions(), destRect);
            }

            //ExEnd:ExpandandCropImages
        }