1. Tech

Your suggestion is on its way!

An email with a link to:


was emailed to:

Thanks for sharing About.com with others!

RTL referenceGlossary|Tips/Tricks|FREE App/VCL|Best'O'Net|Books|Link To
GDI Graphics In Delphi
Page 1: GDI Jargon
 More of this Feature
• Page 2: Drawing: Lines
• Page 3: Drawing: Shapes
• Page 4: Draw vs. Paint
• Page 5: Handles and Stuff
• Page 6: Pictures: TBitmap
• Page 7: Ways To Kill Flicker
• Page 8: GDI, The Hard Way
• Page 9: API Drawings
 Join the Discussion
"Post your views, comments, questions and doubts to this article."
 Related Resources
• Graphics programming in Delphi
• Screen zooming
• Double buffering
• Win API in Delphi

Article submitted by: Alistair Keys

   Umm, GDI You Say?
GDI stands for Graphics Device Interface, and is the interface that Windows uses for drawing 2D graphics. It is also, unfortunately, the slowest method around, but is useful for basic graphics. This tutorial will introduce you to some of the jargon and terms in the GDI.

The first point to note is that you should not attempt to use the GDI for any fancy graphical effects, like cross-fading pictures, as it is a bit primitive. For professional-looking graphics try using DirectX, OpenGL, or a graphics library (e.g. any of these, among others: DelphiX, FastLib, DIBUltra, Graphics32...). However, you can use the GDI for some neat effects, with a little creativity.

   Anything Else I Should Know?
One common acronym you will find with GDI is DC ("Device Context"). This is what you draw on, and is represented in Delphi by TCanvas. The idea behind device contexts is to abstract the output device details, so you can use the same drawing functions for (e.g.) a screen or a printer.

Another (pretty important) note is that you will start by using the standard Delphi graphics functions, as these are wrappers for the GDI functions of Windows. When the need arises, I will describe the Windows GDI functions for which Delphi provides a nice interface.

   Enough Jargon! Let's Draw!
Patience, my friend. You will be drawing pretty pictures soon enough. First, you need to know a little about how the GDI is organized. Here are some classes of importance:

Pen This is used to draw simple lines. Examples are the LineTo function, or drawing the border for some shapes (e.g. the function Rectangle).
Brush A brush is used to fill areas with color. Examples are the functions Rectangle, FillRect or FloodFill.
Font Intuitively, this is just the font to use for any text drawing you need. You can specify font name, size, etc.
Region A region is Windows-speak for an enclosed space. This could mean a circle, square, dodecahedron, or anything. It can have holes in the shape, too.

Now you've experienced some silly jargon we can start to draw things. We'll take it easy and begin with lines and shapes.

   Question, Suggestions...
If you have any questions or comments to this (huge) article, please post them on the Delphi Programming Forum. Discuss!

Next page > Drawing lines > Page 1, 2, 3, 4, 5, 6, 7, 8, 9

All graphics (if any) in this feature created by Zarko Gajic.

 More Delphi
· Learn another routine every day - RTL Quick Reference.
· Download free source code applications and components.
· Talk about Delphi Programming, real time.
· Link to the Delphi Programming site from your Web pages.
· Tutorials, articles, tech. tips by date: 2001|2000|1999|1998 or by TOPIC.
· NEXT ARTICLE: Articles.
More Delphi articles
 Stay informed with all new and interesting things about Delphi (for free).
Subscribe to the Newsletter

 Got some code to share? Got a question? Need some help?

©2016 About.com. All rights reserved.