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;

            //Create an instance of System.IO.Stream
            System.IO.Stream stream = new System.IO.FileStream(dataDir + "sample.bmp", System.IO.FileMode.Create);

            //Define the source property for the instance of BmpOptions
            //Second boolean parameter determines if the Stream is disposed once get out of scope
            ImageOptions.Source = new Aspose.Imaging.Sources.StreamSource(stream, true);

            //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))
            {
                //do some image processing
                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 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 RasterImage
            using (Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Create(ImageOptions, 500, 500))
            {
                //Get the pixels of the image by specifying the area as image boundary
                Color[] pixels = rasterImage.LoadPixels(rasterImage.Bounds);

                for (int index = 0; index < pixels.Length; index++)
                {
                    //Set the indexed pixel color to yellow
                    pixels[index] = Color.Yellow;
                }

                //Apply the pixel changes to the image
                rasterImage.SavePixels(rasterImage.Bounds, pixels);

                // Save all changes.
                rasterImage.Save();
            }
        }
Esempio n. 3
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 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();
                }
            }
        }
        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 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: ExportImagesInMultiThreadedEnvironment

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

            string imageDataPath = "";

            try
            {
                // Path & name of existing image.
                imageDataPath = dataDir + "sample.bmp";

                // Create the stream of the existing image file.
                using (System.IO.FileStream fileStream = System.IO.File.Create(imageDataPath))
                {
                    // Create an instance of BMP image option class.
                    using (Aspose.Imaging.ImageOptions.BmpOptions bmpOptions = new Aspose.Imaging.ImageOptions.BmpOptions())
                    {
                        bmpOptions.BitsPerPixel = 32;

                        // Set the source property of the imaging option class object.
                        bmpOptions.Source = new Aspose.Imaging.Sources.StreamSource(fileStream);

                        // DO PROCESSING.
                        // Following is the sample processing on the image. Un-comment to use it.
                        //using (RasterImage image = (RasterImage)Image.Create(bmpOptions, 10, 10))
                        //{
                        //    Color[] pixels = new Color[4];
                        //    for (int i = 0; i < 4; ++i)
                        //    {
                        //        pixels[i] = Color.FromArgb(40, 30, 20, 10);
                        //    }
                        //    image.SavePixels(new Rectangle(0, 0, 2, 2), pixels);
                        //    image.Save();
                        //}
                    }
                }
            }
            finally
            {
                // Delete the file. This statement is in the final block because in any case this statement should execute to make it sure that resource is properly disposed off.
                System.IO.File.Delete(imageDataPath);
            }


            // ExEnd: ExportImagesInMultiThreadedEnvironment
        }
Esempio n. 9
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 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();
                }
            }
        }
        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();
            }
        }
Esempio n. 12
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();
                }
            }
        }
        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();
                }
            }
        }