RAD Studio
ContentsIndex
PreviousUpNext
Using a Picture, Graphic, or Canvas

There are three kinds of classes in Delphi that deal with graphics:

  • A canvas represents a bitmapped drawing surface on a form, graphic control, printer, or bitmap. A canvas is always a property of something else, never a stand-alone class.
  • A graphic represents a graphic image of the sort usually found in a file or resource, such as a bitmap, icon, or metafile. Delphi defines classes TBitmap, TIcon, and TMetafile, all descended from a generic TGraphic. You can also define your own graphic classes. By defining a minimal standard interface for all graphics, TGraphic provides a simple mechanism for applications to use different kinds of graphics easily.
  • A picture is a container for a graphic, meaning it could contain any of the graphic classes. That is, an item of type TPicture can contain a bitmap, an icon, a metafile, or a user-defined graphic type, and an application can access them all in the same way through the picture class. For example, the image control has a property called Picture, of type TPicture, enabling the control to display images from many kinds of graphics.
Keep in mind that a picture class always has a graphic, and a graphic might have a canvas. (The only standard graphic that has a canvas is TBitmap.) Normally, when dealing with a picture, you work only with the parts of the graphic class exposed through TPicture. If you need access to the specifics of the graphic class itself, you can refer to the picture's Graphic property.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!