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 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(); } }
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(); } } }