Click here to Skip to main content
Licence 
First Posted 18 Feb 2004
Views 47,384
Bookmarked 23 times

Using Dynamic Graphics in C#

By | 18 Feb 2004 | Article
An article on the practical uses of dynamic graphics

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.

/// 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

About the Author

cgreen69

Software Developer (Senior)

United Kingdom United Kingdom

Member

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.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionIs it really article?! Pinmembersoad17152:03 19 Aug '11  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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 | Mobile
Web01 | 2.5.120517.1 | Last Updated 19 Feb 2004
Article Copyright 2004 by cgreen69
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid