Search code examples
delphigraphicsdelphi-2009gdi

Options for pure-graphics display in Delphi 2009


My whole experience with direct use of graphics consists of drawing shapes using Turbo Pascal’s gdi unit on a 386 machine ages ago, finding it unbearably slow and never giving it a second thought. In other words, I have next to no idea where to begin.

For a simple Internet radio player application, I would like to design a graphic display somewhat similar to Winamp (but a bit larger and easier on the eyes, since the illegibility of such displays is one reason I’m trying to do my own).

Simple graphic components like those imitating LED displays are nowhere near sufficient, of course. I don’t expect to be drawing clickable UI controls, and certainly not skins – just the readout, with text, digits and a few symbols. I understand Delphi 2010 supports Direct2D, but I only have D2009.

What are my options? Are there any 3rd party components that would help?

On edit two small points. I need the drawing to be flicker-free (i.e,, unlike what I experienced all those years ago in Turbo Pascal :-). Is TCanvas going to be fast enough for that? Also, I would probably want to use alphablending, which I don't think I can get with the basic TextOut, LineTo etc. graphics API. (I just don't know what's possible). What about GDI+?


Solution

  • A library for fast 2D graphics for Delphi is available as open source on Sourceforge:

    Graphics32 (home page: http://www.graphics32.org/)

    Graphics32 is a graphics library for Delphi and Kylix/CLX. Optimized for 32-bit pixel formats, it provides fast operations with pixels and graphic primitives. In most cases Graphics32 considerably outperforms the standard TBitmap/TCanvas methods.

    Features Some of Graphics32 features include:

    • Fast per-pixel access up to 100 times faster compared to standard TBitmap;
    • High-performance Bitmap alpha blending (including per-pixel alpha blending);
    • Pixel, line and polygon antialiasing with sub-pixel accuracy (combined with alpha blending);
    • Arbitrary polygon transformations and custom fillings;
    • Bitmap resampling with high quality reconstruction filters (e.g. Lanczos, Cubic, Mitchell);
    • A unique state-of-the-art rasterization system;
    • Affine transformations of bitmaps: rotations, scaling, etc with sub-pixel accuracy;
    • Arbitrary projective transformations of bitmaps;
    • Arbitrary remapping transformations of bitmaps (e.g. for Warping, Morphing);
    • Flexible supersampling implementation for maximum sampling quality;
    • Flicker-free image displaying components with optimized double buffering via advanced MicroTiles based repaint optimizer;
    • Multiple customizible easy-to-use overlay layers;
    • Locking of bitmaps for safe multithreading;
    • A property editor for RGB and alpha channel loading;
    • Design-time loading of image formats supported by standard TPicture;
    • Works on Borland Delphi, C++ Builder and Kylix (The last version that supported Kylix was 1.8.3).

    As of version 1.5.1b Graphics32 is licensed under the terms of the Mozilla Public License.