Guide for C#
Core Document Formats
Additional Features
Draw .NET Graphics

C# Imaging - C# Code to Draw .NET Graphics

Free Visual C# Codes for Drawing .NET Graphics in .NET Image Project

Visual C#
Home > .NET Imaging SDK > C# > Draw .NET Graphics
If this is your first time to use our DocImageSDK, we strongly suggest you reading How to Start first!

Draw .NET Graphics in C# Overview
With powerful image drawing function of .NET Imaging SDK, developers and programmers are competent to draw both text and .NET graphics within the assistance of C# demo code. This page shows the detailed guide on how to draw .NET graphics with the standard options in C# application. The main image .NET graphics writing functions include:
Related .net document control helps:
asp.net pdf document viewer: ASP.NET PDF Document Viewer in C#: open, display, view, annotate, redact Adobe PDF files online in ASP.NET MVC & WebForm...
asp.net ppt viewer: ASP.NET PowerPoint Document Viewer Control (MVC & WebForms): view ppt, pptx files online in C# using ASP.NET
asp.net pdf page: ASP.NET PDF Pages Edit Control: add, remove, sort, replace PDF pages online using C#
asp.net excel web viewer: ASP.NET Excel Viewer in C# Control (MVC & WebForms): view Office Excel document in web browser.
sharepoint document viewer: ASP.NET SharePoint Document Viewer: view, annotate, redact documents in SharePoint
asp.net word document viewer: ASP.NET Office Word Document Viewer: view Word doc files online using C# in ASP.NET MVC web applications
asp.net mvc document viewer: ASP.NET MVC Document Viewer: view, annotate, redact files on ASP.NET MVC web projects
  • Draw rectangle image on .NET graphics using RectangleDrawing method
  • Write line shape on .NET graphics using LineDrawing method
  • Add ellipse object on .NET graphics using EllipseDrawing method
In this image .NET graphics drawing tutorial article, users are supposed to learn:
  • Specific function features of using image .NET graphics application in C# project
  • Step by step guide on how to create a C# application to draw .NET graphics
  • Complete method and sample code to make users draw .NET graphics easily
Function Features of .NET Graphics Drawing in C#
  • Simple to incorporate image drawing controls within your C#.NET applications
  • Run .NET imaging graphics application within a few seconds in C# project
  • Support pre-processing options for better .NET graphics drawing
  • General pre-processing operations contain choosing a proper color, setting graphics width & height and deciding the font style property
  • Full support to draw variable image shapes on .NET graphics, like ellipse, rectangle, line, rubber stamp, etc.
  • Display the added image on .NET graphics at best status within C# code
  • Save drawn image to PNG, BMP, GIF, TIFF and JPEG image formats
  • Multiple storage options of image in .NET graphics including local file, database and memory
How to Draw .NET Graphics in C# Program
Before applying the function of image .NET graphics drawing, you need to create a proper Visual C# Windows project first. And this part tells users how to create such a C# application. For VB.NET developers, please go to draw .NET graphics within .NET Imaging SDK in VB.NET. Want to view image and document in WinForms or web applications, please go to draw .NET graphics in WinForms and web document image .NET graphics drawing.
  1. Open and run Microsoft Visual Studio 2005/2008/2010 at first;
  2. Then, you are supposed to create a C#.NET project;
  3. Later, please copy your.NET imaging license text file to the new C# Windows project folder;
  4. Add following image drawing and basic references to your C# project;
    • RasterEdge.Imaging.Drawing.dll
    • RasterEdge.Imaging.Basic.dll
  5. Add following using requirements in C# project:
using System.IO;
using System.Drawing.Printing;
using RasterEdge.Imaging;
using RasterEdge.Imaging.Processing;
using RasterEdge.Imaging.Drawing.Image.Text;
C# .NET Graphics Drawing Methods
Following .NET graphics drawing methods allow programmers and end users to draw rectangle, line, and ellipse images in your C# applications.
public void RectangleDrawing(Pen mypen, Rectangle myRectangle);
public void RectangleDrawing(Pen mypen, Point pt1, Point pt2);
public void EllipseDrawing(Pen maypen, Point pt1, Point pt2, Point pt3, Point pt4);
Entire C# Code to Draw Rectangle, Line & Ellipse on .NET Graphics
From following three parts, users can have a better guidance on how to add rectangle, ellipse and line images on .NET graphics by using given C# sample codes.

C# Code to Draw Rectangle Image on .NET Graphics

Following C# demo code demonstrates how to draw a rectangle image on C#.NET Windows graphics. .NET graphics pre-editing applications includes adjusting .NET graphics background color, four edge data and choosing the image shape that will be drawn.
RasterEdgeImaging Rectangle = new RasterEdgeImaging();

{
Bitmap LoadImage = new Bitmap("C:\\1.jpg");
Graphic Rectangle = Graphics.FromImage(LoadImage);
Pen myPen = new Pen(System.Drawing.Color.Red, 5);
Rectangle myRectangle = new Rectangle(20, 20, 250, 200);
}
Rectangle.RectangleDrawing = (mypen, myrectangle);
Rectangle.Save();

C# Code to Draw Line Image to .NET Graphics

Like drawing rectangle image on .NET graphics, adding a line object to graphics is also easy to be achieved. Please follow the complete C# sample code below to finish this work easily.
RasterEdgeImaging Rectangle = new RasterEdgeImaging();

{
Bitmap LoadImage = new Bitmap("C:\\Sample.png");
Graphic Linear = Graphics.FromImage(LoadImage);
Pen myPen = new Pen(System.Drawing.Color.Red, 5);
Point pt1 = new Point (10.0F, 30.0F);
Point pt2 = new Point (50.0F, 30.0F);
}
Linear.LinearDrawing = (mypen, pt1, pt2);
Linear.Save();

C# Code to Draw Ellipse Image to .NET Graphics

Following Visual C# demo code demonstrates how to draw an ellipse object to .NET graphics. If you are interested image drawing functions in VB.NET project, please have a look at: how to draw and write image text and .NET graphics in VB.NET class.
RasterEdgeImaging Rectangle = new RasterEdgeImaging();

{
Bitmap LoadImage = new Bitmap("C:\\Sample.png");
Graphic Rectangle = Graphics.FromImage(LoadImage);
Pen myPen = new Pen (Color.Black, 3);
Rectangle myRectangle = new Rectangle(20, 20, 250, 200);
}
Ellipse. EllipseDrawing = (mypen, pt1, pt2, pt3, pt4);
Ellipse.Save();


Recommend this to Google+


RasterEdge.com is professional provider of ASP.NET MVC Document Viewer, ASP.NET PDF Viewer, MVC PDF Viewer document, content and imaging solutions, available for ASP.NET AJAX, Silverlight, Windows Forms as well as WPF. We are dedicated to provide powerful & profession imaging controls, PDF document, image to pdf files and components for capturing, viewing, processing, converting, compressing and stroing images, documents and more.

©2000-2023 Raster Edge.com