Click here to Skip to main content
15,893,663 members
Articles / Web Development / ASP.NET
Article

Using Dynamic Graphics in C#

Rate me:
Please Sign up or sign in to vote.
2.33/5 (6 votes)
18 Feb 20041 min read 61.6K   948   23   1
An article on the practical uses of dynamic graphics

Image 1

Introduction

The dynamic creation of graphics within the .Net Framework is a powerful feature that can be adapted to a wide range of purposes. Here I have developed a demonstration that

  • a) generates graphics dynamically from text inputted by a user
  • b) mixes dynamic graphics with a static graphic to show you how flexible .Net graphic handling is.

The graphic routines lend themselves to any environment where a standard look and feel needs to be applied with a minimum of effort.

Using the code

The attached project file contains an ASPX file which has a handful of HTML controls allowing the user to specify two pieces of text that will be transformed into our XP style header bars. The code behind file inspects these controls and instantiates an instance of the CompleteImage Class. The CompleteImage class in turn instantiates instances of the HeaderImage inner class that are responsible for the nice anti aliased text bars you’ll see in the final image. The ComplteImage class is responsible for building a bitmap that combines the users text and heading bars and exposes the finished product via the CANVAS property.

C#
/// Instantiating a CompleteImage object
CompleteImage ci = new CompleteImage (
  "header one","header two","test");

/// Addi/// Adding a header to our CompleteImage object
d.DrawImage(((HeaderImage) new HeaderImage(
  this.headercolor,"text to display")).IMAGE,0,0); 

Points of Interest

The HeaderImage class is overloaded. One of the constructors allows the developer to specify the color of the header bar they would like to create. Functionality like this can save a lot of time, traditionally a designer would have to create a new version of the graphic in a paint application and save it to the web server.

History

  • 16.01.04 Version 1.0 released

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior)
United Kingdom United Kingdom
A .net devotee specialising in Object Orientated web development for financial institutions in Europe. When not working can normally be found at a bar within walking distance of the office.

Comments and Discussions

 
QuestionIs it really article?! Pin
MeRobot19-Aug-11 2:03
MeRobot19-Aug-11 2: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.