Click here to Skip to main content
Click here to Skip to main content

Using Dynamic Graphics in C#

By , 18 Feb 2004
Rate this:
Please Sign up or sign in to vote.

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
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?! Pinmembersoad171519-Aug-11 2:03 

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.

| Advertise | Privacy | Mobile
Web04 | 2.8.140421.2 | Last Updated 19 Feb 2004
Article Copyright 2004 by cgreen69
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid