
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.
CompleteImage ci = new CompleteImage (
“header one”,”header two”,”test”);
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
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