Created
June 26, 2020 09:55
-
-
Save aspose-com-gists/0c035ac54f3ae3fc794e8a7e10c5a85b to your computer and use it in GitHub Desktop.
Create or update images using C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create Bitmap object | |
Bitmap bitmap = new Bitmap(1000, 800, System.Drawing.Imaging.PixelFormat.Format32bppPArgb); | |
// Create and initialize Graphics | |
Graphics graphics = Graphics.FromImage(bitmap); | |
// Create Pen | |
Pen pen = new Pen(Color.FromKnownColor(KnownColor.Blue), 2); | |
// Draw arc | |
graphics.DrawArc(pen, 0, 0, 700, 700, 0, 180); | |
// Create another Pen | |
Pen pen1 = new Pen(Color.FromKnownColor(KnownColor.Red), 2); | |
// Draw ellipse | |
graphics.DrawEllipse(pen1, 10, 10, 900, 700); | |
// Save the drawing into desired image format | |
bitmap.Save(@"drawing.png"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Initialize Bitmap with the input image | |
Bitmap bitmap = new Bitmap("input.png"); | |
// Initialize graphics | |
Graphics graphics = Graphics.FromImage(bitmap); | |
// Create a Pen | |
Pen pen = new Pen(Color.FromKnownColor(KnownColor.Orange), 4); | |
// Draw polygon | |
graphics.DrawPolygon(pen, new Point[] { new Point(100, 100), new Point(500, 400), new Point(900, 100) }); | |
// Save the drawing into desired image format | |
bitmap.Save(@"drawing_updated.png"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment