Multicolored Gradient

Multicolor Gradients: An Introduction to Working with Palette Effects

Working with color palettes is one of the fundamental aspects of 2D rendering. I’ve gone over the various color depths used in computer graphics in a earlier post on rendering with GDI, however there are a couple of aspects I didn’t directly mention.

Specifically, the biggest advantage in using a color palette is the sizable speed advantage you gain by having a fixed amount of colors that allow for a direct index into the color table that correspond to a range of values generated by your effect.

I’ll have a more in-depth discussion on this topic in a follow-up post; for now let’s take a look at the steps needed to generate a gradient palette with a variable amount of colors, which is needed by a variety of effects, and a brief introduction to working with pointers in C# so that we can display our gradients to the screen in an efficient manner.

Continue reading

Rendering Framework: GDI via C#

When developing graphical applications in a Windows environment, one of the key fundamental aspects for creating rich applications is understanding the “Graphics Device Interface” or, more commonly known as, simply GDI.

GDI is an abstraction layer for accessing video hardware built into the Windows operating system, specifically residing in the “GDI32.dll”.

This abstraction layer is responsible for drawing geometrical shapes, text with various fonts and sizes, handling various color depths – most commonly 8-bpp (256 colors represented by a palette – indexed, monochrome or “real color”), 16-bpp (“high color”), 24-bpp (“true color”) and 32-bpp ( “true color with transparency”) and rendering results to a Device Context – such as a screen or a printer.

Continue reading

Rendering Framework: Real-time Drawing with C#

One of the first things that truly broadened my horizons on how amazing software development could be, was when I saw my first “Demo”. A demo is simply a non-interactive real-time display of a visualization effect. Some of the most classic (and simple) examples are the Starfield, Plasma, Fire and Water. The real appeal of these first demos was that developers, on basically identical hardware, could really display their algorithm optimization talents – some going as far as exploiting hardware defects to achieve faster rendering routines.

Continue reading