Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Aspose.Imaging.Examples.Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);

            if (!IsExists)
            {
                System.IO.Directory.CreateDirectory(dataDir);
            }

            //Creates an instance of BmpOptions and set its various properties
            Aspose.Imaging.ImageOptions.BmpOptions ImageOptions = new Aspose.Imaging.ImageOptions.BmpOptions();
            ImageOptions.BitsPerPixel = 24;


            //Define the source property for the instance of BmpOptions
            //Second boolean parameter determines if the file is temporal or not
            ImageOptions.Source = new Aspose.Imaging.Sources.FileCreateSource(dataDir + "output.bmp", false);


            //Creates an instance of Image and call Create method by passing the BmpOptions object
            using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Create(ImageOptions, 500, 500))
            {
                image.Save();
            }
        }
Exemplo n.º 2
0
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Aspose.Imaging.Examples.Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            //Create an instance of BmpCreateOptions and set its various properties
            //Create an instance of BmpOptions and set its various properties
            Aspose.Imaging.ImageOptions.BmpOptions ImageOptions = new Aspose.Imaging.ImageOptions.BmpOptions();
            ImageOptions.BitsPerPixel = 24;

            //Create an instance of FileCreateSource and assign it to Source property
            ImageOptions.Source = new Aspose.Imaging.Sources.FileCreateSource(dataDir + "sample.bmp", false);

            //Create an instance of Image
            using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Create(ImageOptions, 500, 500))
            {
                //Create and initialize an instance of Graphics
                Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(image);

                //Clear the image surface with white color
                graphics.Clear(Aspose.Imaging.Color.White);

                //Create an instance of GraphicsPath
                Aspose.Imaging.GraphicsPath graphicspath = new Aspose.Imaging.GraphicsPath();

                //Create an instance of Figure
                Aspose.Imaging.Figure figure = new Aspose.Imaging.Figure();

                //Add EllipseShape to the figure by defining boundary Rectangle
                figure.AddShape(new EllipseShape(new RectangleF(0, 0, 499, 499)));

                //Add RectangleShape to the figure
                figure.AddShape(new RectangleShape(new RectangleF(0, 0, 499, 499)));

                //Add TextShape to the figure by defining the boundary Rectangle and Font
                figure.AddShape(new TextShape("Aspose.Imaging", new RectangleF(170, 225, 170, 100), new Font("Arial", 20), StringFormat.GenericTypographic));

                //Add figures to the GraphicsPath object
                graphicspath.AddFigures(new Aspose.Imaging.Figure[] { figure });

                //Draw Path
                graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue), graphicspath);

                //Create an instance of HatchBrush and set its properties
                Aspose.Imaging.Brushes.HatchBrush hatchbrush = new Aspose.Imaging.Brushes.HatchBrush();
                hatchbrush.BackgroundColor = Aspose.Imaging.Color.Brown;
                hatchbrush.ForegroundColor = Color.Blue;
                hatchbrush.HatchStyle      = HatchStyle.Vertical;

                //Fill path by supplying the brush and GraphicsPath objects
                graphics.FillPath(hatchbrush, graphicspath);

                // Save the changes.
                image.Save();

                // Display Status.
                System.Console.WriteLine("Processing completed successfully.");
            }
        }
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Aspose.Imaging.Examples.Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);

            if (!IsExists)
            {
                System.IO.Directory.CreateDirectory(dataDir);
            }

            //Creates an instance of FileStream
            using (System.IO.FileStream stream = new System.IO.FileStream(dataDir + "outputlines.bmp", System.IO.FileMode.Create))
            {
                //Create an instance of BmpOptions and set its various properties
                Aspose.Imaging.ImageOptions.BmpOptions saveOptions = new Aspose.Imaging.ImageOptions.BmpOptions();
                saveOptions.BitsPerPixel = 32;

                //Set the Source for BmpOptions
                saveOptions.Source = new Aspose.Imaging.Sources.StreamSource(stream);

                //Create an instance of Image
                using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Create(saveOptions, 100, 100))
                {
                    //Create and initialize an instance of Graphics class
                    Aspose.Imaging.Graphics graphic = new Aspose.Imaging.Graphics(image);

                    //Clear Graphics surface
                    graphic.Clear(Color.Yellow);

                    //Draw two dotted diagonal lines by specifying the Pen object having blue color and co-ordinate Points
                    graphic.DrawLine(new Pen(Color.Blue), 9, 9, 90, 90);
                    graphic.DrawLine(new Pen(Color.Blue), 9, 90, 90, 9);

                    //Draw a continuous line by specifying the Pen object having Solid Brush with red color and two point structures
                    graphic.DrawLine(new Pen(new Aspose.Imaging.Brushes.SolidBrush(Color.Red)), new Point(9, 9), new Point(9, 90));

                    //Draw a continuous line by specifying the Pen object having Solid Brush with aqua color and two point structures
                    graphic.DrawLine(new Pen(new Aspose.Imaging.Brushes.SolidBrush(Color.Aqua)), new Point(9, 90), new Point(90, 90));

                    //Draw a continuous line by specifying the Pen object having Solid Brush with black color and two point structures
                    graphic.DrawLine(new Pen(new Aspose.Imaging.Brushes.SolidBrush(Color.Black)),
                                     new Point(90, 90), new Point(90, 9));

                    //Draw a continuous line by specifying the Pen object having Solid Brush with white color and two point structures
                    graphic.DrawLine(new Pen(new Aspose.Imaging.Brushes.SolidBrush(Color.White))
                                     , new Point(90, 9), new Point(9, 9));


                    // save all changes.
                    image.Save();
                }
            }
        }
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Aspose.Imaging.Examples.Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);

            if (!IsExists)
            {
                System.IO.Directory.CreateDirectory(dataDir);
            }

            //Creates an instance of FileStream
            using (System.IO.FileStream stream = new System.IO.FileStream(dataDir + "outputlines.bmp", System.IO.FileMode.Create))
            {
                //Create an instance of BmpOptions and set its various properties
                Aspose.Imaging.ImageOptions.BmpOptions saveOptions = new Aspose.Imaging.ImageOptions.BmpOptions();
                saveOptions.BitsPerPixel = 32;

                //Set the Source for BmpOptions
                saveOptions.Source = new Aspose.Imaging.Sources.StreamSource(stream);

                //Create an instance of Image
                using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Create(saveOptions, 100, 100))
                {
                    //Create and initialize an instance of Graphics class
                    Aspose.Imaging.Graphics graphic = new Aspose.Imaging.Graphics(image);

                    //Clear Graphics surface
                    graphic.Clear(Color.Yellow);

                    //Initializes the instance of PEN class with black color and width
                    Pen BlackPen = new Pen(Color.Black, 3);

                    float startX    = 10;
                    float startY    = 25;
                    float controlX1 = 20;
                    float controlY1 = 5;
                    float controlX2 = 55;
                    float controlY2 = 10;
                    float endX      = 90;
                    float endY      = 25;


                    //Draw a Bezier shape by specifying the Pen object having black color and co-ordinate Points
                    graphic.DrawBezier(BlackPen, startX, startY, controlX1, controlY1, controlX2, controlY2, endX, endY);



                    // save all changes.
                    image.Save();
                }
            }
        }
Exemplo n.º 5
0
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Aspose.Imaging.Examples.Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);

            if (!IsExists)
            {
                System.IO.Directory.CreateDirectory(dataDir);
            }

            //Creates an instance of FileStream
            using (System.IO.FileStream stream = new System.IO.FileStream(dataDir + "outputarc.bmp", System.IO.FileMode.Create))
            {
                //Create an instance of BmpOptions and set its various properties
                Aspose.Imaging.ImageOptions.BmpOptions saveOptions = new Aspose.Imaging.ImageOptions.BmpOptions();
                saveOptions.BitsPerPixel = 32;

                //Set the Source for BmpOptions
                saveOptions.Source = new Aspose.Imaging.Sources.StreamSource(stream);

                //Create an instance of Image
                using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Create(saveOptions, 100, 100))
                {
                    //Create and initialize an instance of Graphics class
                    Aspose.Imaging.Graphics graphic = new Aspose.Imaging.Graphics(image);

                    //Clear Graphics surface
                    graphic.Clear(Color.Yellow);

                    //Draw an arc shape by specifying the Pen object having red black color and coordinates, height, width, start & end angles
                    int x          = 0;
                    int y          = 0;
                    int width      = 100;
                    int height     = 200;
                    int startAngle = 45;
                    int sweepAngle = 270;

                    // Draw arc to screen.
                    graphic.DrawArc(new Pen(Color.Black), 0, 0, width, height, startAngle, sweepAngle);

                    // save all changes.
                    image.Save();
                }

                stream.Close();
            }
        }
        public static void Run()
        {
            //ExStart:MultipleImagesToTIFF
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages();
            //String path = @"C:\Imaging Data\IMG\";
            int page      = 0;
            var tempImage = Aspose.Imaging.Image.Load(dataDir + "Image1.png");
            int width     = 500;
            int height    = 500;

            width  = tempImage.Width;
            height = tempImage.Height;
            Aspose.Imaging.ImageOptions.TiffOptions tiffOptions = new Aspose.Imaging.ImageOptions.TiffOptions(TiffExpectedFormat.Default);
            tiffOptions.Source = new Aspose.Imaging.Sources.FileCreateSource(dataDir + "MultiPage.tiff", false);

            //Create an instance of Image and initialize it with instance of BmpOptions by calling Create method
            using (TiffImage TiffImage = (TiffImage)Aspose.Imaging.Image.Create(tiffOptions, width, height))
            {
                //do some image processing
                DirectoryInfo di    = new DirectoryInfo(dataDir);
                FileInfo[]    files = di.GetFiles("*.img");
                int           index = 0;
                foreach (var file in files)
                {
                    using (Aspose.Imaging.Image inputImage = Aspose.Imaging.Image.Load(file.FullName))
                    {
                        inputImage.Resize(width, height, ResizeType.NearestNeighbourResample);
                        //  var frame = TiffImage.ActiveFrame;
                        if (index > 0)
                        {
                            var newframe = new TiffFrame(tiffOptions, width, height);
                            TiffImage.AddFrame(newframe);
                            int cnt = TiffImage.Frames.Count();
                        }
                        var frame = TiffImage.Frames[index];
                        frame.SavePixels(frame.Bounds, ((RasterImage)inputImage).LoadPixels(inputImage.Bounds));

                        index += 1;
                    }
                }

                // save all changes
                TiffImage.Save(dataDir + "output.tiff");
            }
        }
Exemplo n.º 7
0
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Aspose.Imaging.Examples.Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);

            if (!IsExists)
            {
                System.IO.Directory.CreateDirectory(dataDir);
            }

            //Creates an instance of FileStream
            using (System.IO.FileStream stream = new System.IO.FileStream(dataDir + "outputlines.bmp", System.IO.FileMode.Create))
            {
                //Create an instance of BmpOptions and set its various properties
                Aspose.Imaging.ImageOptions.BmpOptions saveOptions = new Aspose.Imaging.ImageOptions.BmpOptions();
                saveOptions.BitsPerPixel = 32;

                //Set the Source for BmpOptions
                saveOptions.Source = new Aspose.Imaging.Sources.StreamSource(stream);

                //Create an instance of Image
                using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Create(saveOptions, 100, 100))
                {
                    //Create and initialize an instance of Graphics class
                    Aspose.Imaging.Graphics graphic = new Aspose.Imaging.Graphics(image);

                    //Clear Graphics surface
                    graphic.Clear(Color.Yellow);

                    //Draw a rectangle shape by specifying the Pen object having red color and a rectangle structure
                    graphic.DrawRectangle(new Pen(Color.Red), new Rectangle(30, 10, 40, 80));

                    //Draw a rectangle shape by specifying the Pen object having solid brush with blue color and a rectangle structure
                    graphic.DrawRectangle(new Pen(new Aspose.Imaging.Brushes.SolidBrush(Color.Blue)), new Rectangle(10, 30, 80, 40));

                    // save all changes.
                    image.Save();
                }
            }
        }
Exemplo n.º 8
0
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Aspose.Imaging.Examples.Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            //Load an existing image
            using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dataDir + "sample.bmp"))
            {
                //Create an instance of PsdOptions and set it’s various properties
                Aspose.Imaging.ImageOptions.PsdOptions psdOptions = new Aspose.Imaging.ImageOptions.PsdOptions();
                psdOptions.ColorMode         = Aspose.Imaging.FileFormats.Psd.ColorModes.RGB;
                psdOptions.CompressionMethod = Aspose.Imaging.FileFormats.Psd.CompressionMethod.Raw;
                psdOptions.Version           = 4;

                //Save image to disk in PSD format
                image.Save(dataDir + "output.psd", psdOptions);

                // Display Status.
                System.Console.WriteLine("Export to PSD performed successfully.");
            }
        }
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Aspose.Imaging.Examples.Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            //Load an existing image (of type Gif) in an instance of the Image class
            using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dataDir + "sample.gif"))
            {
                //Export to BMP file format using the default options
                image.Save(dataDir + "output.bmp", new Aspose.Imaging.ImageOptions.BmpOptions());

                //Export to JPEG file format using the default options
                image.Save(dataDir + "output.jpeg", new Aspose.Imaging.ImageOptions.JpegOptions());

                //Export to PNG file format using the default options
                image.Save(dataDir + "output.png", new Aspose.Imaging.ImageOptions.PngOptions());

                //Export to TIFF file format using the default options
                image.Save(dataDir + "output.tiff", new Aspose.Imaging.ImageOptions.TiffOptions(Aspose.Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.Default));
            }

            // Display Status.
            System.Console.WriteLine("Conversion performed successfully.");
        }