Click here to Skip to main content
13,863,642 members
Click here to Skip to main content
Add your own
alternative version


86 bookmarked
Posted 29 Nov 2006
Licenced CPOL

Simple SVG Editor

, 18 Sep 2007
Rate this:
Please Sign up or sign in to vote.
This application is a combination of two projects from The Code Project: DrawTools by Alex Fry and SVGPad by Maurizio Bigoloni


SvgPaint is the simplest SVG editor. This application is a combination of two projects from The Code Project: DrawTools by Alex Fry and SVGPad by Maurizio Bigoloni. This application implements only trivial graphics elements from SVG format, no rendering, no transforming, etc.

Sample screenshot

How It Works

Sample screenshot

SvgLib reads and parses the Svg file and creates object SvgDoc with SvgElements.

Then, from SvgElements, create the DrawObjects, objects by DrawObject library.

After editing using the DrawTools library, the graphics objects may be saved in the edited Svg file.

I do not use serialization because it is used in the DrawTools project. I added to DrawObjects static methods that create an XML string with graphic elements in Svg format.

I also added a few graphics classes into used projects:

  • SvgPolyline into SvgPad
  • DrawText, DrawImage into DrawTools

Moreover, I added scaling capability and filling.

How to Transform Svg Elements to Draw Objects

After created SvgDoc, calling recursing method AddFromSvg() (beginning from root element), that, for all Svg elements, calls static method CreateDrawObject() of the DrawObject class:

public void AddFromSvg(SvgElement ele) 
	while (ele != null) 
		DrawObject o = this.CreateDrawObject(ele); 
		if (o != null) 
		SvgElement child = ele.getChild(); 
		while (child != null) 
			child = child.getNext(); 
		ele = ele.getNext(); 

The method CreateDrawObject() of basic class DrawObject has input parameter SvgElement and calls static method Create() of inherited draw objects that create themselves.

Then, the new draw objects add to GraphicsList object:

DrawObject CreateDrawObject(SvgElement svge) 
	DrawObject o = null; 
	switch (svge.getElementType()) 
		case SvgElement._SvgElementType.typeLine: 
			o = DrawLine.Create((SvgLine )svge); 
		case SvgElement._SvgElementType.typeRect: 
			o = DrawRectangle.Create((SvgRect )svge); 
		case SvgElement._SvgElementType.typeEllipse: 
			o = DrawEllipse.Create((SvgEllipse )svge); 
		case SvgElement._SvgElementType.typePolyline: 
			o = DrawPolygon.Create((SvgPolyline )svge); 
		case SvgElement._SvgElementType.typeImage: 
			o = DrawImage.Create((SvgImage )svge); 
		case SvgElement._SvgElementType.typeText: 
			o = DrawText.Create((SvgText )svge); 
		case SvgElement._SvgElementType.typeGroup: 
			o = CreateGroup((SvgGroup )svge); 
	return o; 

Graphics Classes

Sample screenshot

For more details, see DrawTools and SVGPad projects on The Code Project site.

I thank Alex Fry and Maurizio Bigoloni for these interesting projects.


  • 18th September, 2007: I added print/preview and exported into JPG, GIF, PNG formats
  • 16th November, 2006: Initial version 

Contact Details


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Web Developer
Russian Federation Russian Federation
No Biography provided

You may also be interested in...

Comments and Discussions

BugBugs found Pin
Fei Hap Lee8-Apr-14 17:45
memberFei Hap Lee8-Apr-14 17:45 
QuestionAlgorithm Pin
Ashwini615-Dec-12 1:52
memberAshwini615-Dec-12 1:52 
GeneralMy vote of 5 Pin
Manoj Kumar Choubey20-Feb-12 20:27
professionalManoj Kumar Choubey20-Feb-12 20:27 
GeneralGood work Pin
Fco. Javier Marin17-Oct-08 6:47
memberFco. Javier Marin17-Oct-08 6:47 
GeneralNode and Edges Problem Pin
krish_knight32618-Sep-07 23:47
memberkrish_knight32618-Sep-07 23:47 
GeneralRe: Node and Edges Problem Pin
Shokhin21-Sep-07 0:43
memberShokhin21-Sep-07 0:43 
General[Message Removed] Pin
nompel1-Oct-08 8:32
membernompel1-Oct-08 8:32 
GeneralIn the demo,missed the namespace Pin
sun37855475927-Aug-07 3:45
membersun37855475927-Aug-07 3:45 
GeneralRe: In the demo,missed the namespace Pin
Shokhin4-Sep-07 19:24
memberShokhin4-Sep-07 19:24 
QuestionI what to Add more shapes? what i have to do Pin
krish_knight32630-Jul-07 0:03
memberkrish_knight32630-Jul-07 0:03 
AnswerRe: I what to Add more shapes? what i have to do Pin
Shokhin4-Sep-07 19:29
memberShokhin4-Sep-07 19:29 
GeneralForm1.cs(design) is not displaying in .net window Pin
sendnewsletters2-May-07 1:28
membersendnewsletters2-May-07 1:28 
GeneralRe: Form1.cs(design) is not displaying in .net window Pin
Shokhin5-May-07 20:35
memberShokhin5-May-07 20:35 
GeneralThanks for the subject Pin
domanz11127-Mar-07 7:44
memberdomanz11127-Mar-07 7:44 
GeneralThanks for posting Pin
DougKreutzer7-Mar-07 12:36
memberDougKreutzer7-Mar-07 12:36 
QuestionScreenShots missing Pin
Andrew Novik29-Nov-06 20:33
memberAndrew Novik29-Nov-06 20:33 
AnswerRe: ScreenShots missing Pin
Shokhin29-Nov-06 22:30
memberShokhin29-Nov-06 22:30 
GeneralSource code missing Pin
Tony Bermudez29-Nov-06 17:29
memberTony Bermudez29-Nov-06 17:29 
GeneralRe: Source code missing Pin
Shokhin29-Nov-06 23:00
memberShokhin29-Nov-06 23:00 
GeneralRe: Source code missing Pin
Shokhin29-Nov-06 23:03
memberShokhin29-Nov-06 23:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web01 | 2.8.190214.1 | Last Updated 18 Sep 2007
Article Copyright 2006 by Shokhin
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid