Delphi Graphics: Algorithms

A. General Graphics B. Color C. Image Processing D. Mathematics/Geometry

AmazonTechnical.gif (2495 bytes)  in   look for 

Delphi Graphics
Delphi
Graphics
Image Processing


Also see Graphics Reference Library

Overview

Graphics in Delphi Chapter 7, Working with graphics and multimedia
Chapter 36, Using graphics in components
Chapter 40, Creating a graphic component
Borland's Delphi 5 Developer's Guide.

Chapter 22 (online "bonus" chapter)  of  Mastering Delphi 5 by Marco Cantł.

Graphics32 -- a fast graphics library for Delphi
www.g32.org 

Delphi Graphics Programming by Peter Dove and Don Peer in Delphi Informant:
Part I, Jan 97: "A New Spin on Delphi" (pp. 18-32)
Part II, Feb 97: "The World Is Flat" (pp. 48-56)
Part III, Mar 97: "Texture Mapping" (pp. 74-82)
Part IV, Apr 97, "Getting DIBs on Speed" (pp. 45-56)
Part V, July 97, "Optimizing Graphics" (pp. 66-70)
Part VI, Nov 98, "The Camera Never Lies" (pp. 48-55) [Subscription only]
The source code files are now only available to subscribers.

The file names were 
- DI9701DP.ZIP
- DI9702DP.ZIP
- DI9703DP.ZIP
- DI9704DP.ZIP
- DI9707DP.ZIP
- DI9811PD.ZIP

Borland C++ Builder Graphics Tips Page http://norfolkgraphics.com/bcb.php3 
Using graphics in components Chapter 36, Delphi 5 Developer's Guide
Working with graphics and multimedia Chapter 7, Delphi 5 Developer's Guide
Web Programming in Delphi:  Graphics Chapter 21, www.209software.com/books/wpid/ch21.shtml 

Topics

2D Vivid Equations:  An Introduction to 3-D Graphics Programming, Delphi Informant, Aug 1998

[Foley96, 2D Transformations,  pp. 201-204]

2D Transformations in efg's TPantograph class in Lab Reports:
ksupaw.jpg (1358 bytes) Football   or   Sphere In Cube

See Axes on Delphi Graphics Math page

In the Oct 1999 issue of C/C++ Users Journal, there is an article, "An Interactive Drawing Surface Component for C++ Builder," by Anneke Sicherer-Roetman.  In this article she develops a 2D vector drawing component for C++ Builder called TDrawBox. 
ftp://ftp.mfi.com/pub/cuj/1999/cujoct99.zip

3D Vivid Equations:  An Introduction to 3-D Graphics Programming, Delphi Informant, Aug 1998

Delphi Graphics Programming by Peter Dove and Don Peer in Delphi Informant:
Part I, Jan 97: "A New Spin on Delphi" (pp. 18-32). Basic 3D Procedures, Some 3D Theory 

efg's TPantograph in Lab Reports:
Surface3D.gif (956 bytes) z = f(x,y) surface
ThreeDLab.gif (972 bytes)  3D Lab

Non-Delphi: Michael Abrash's Graphics Programming Black Book (out of print), Chapter 54, "3D Shading"

[Foley96, pp. 213-224]]

3D Controls Allow a user to select a viewpoint for a 3D image
www.psychology.nottingham.ac.uk/staff/cr1/3d.html 
Adding graphics to controls Delphi 4 Developer's Guide, pp. 6-13 - 6-17
Alpha blending Encapsulates  the new Windows 2000 API calls for Alpha Blending (transparency).
http://delphi.icm.edu.pl/ftp/d50free/TransparentWnd.zip 

Example component that allows you to create semi-transparent window in Windows 2000.  An Alpha value of 128 looks good (255 is a normal opaque window).  By Paul Mason.

A graphics library, optimized for very fast 32-bit bitmap handling, including alpha blending and antialiasing. Includes  image displaying VCL component with extended scaling properties and a property editor.  http://delphi.icm.edu.pl/ftp/d50free/g32_098.zip

A unit to work with graphics. Many effects like: motion blur, alpha blending, antialiasing, text, texture mapping, save/load  from BMP/TGA.
http://delphi.icm.edu.pl/ftp/d30free/graph64.zip

Non-Delphi:

Windows NT/2000 API Call
http://msdn.microsoft.com/library/psdk/gdi/bitmaps_6ig4.htm 

AlphaBlend with Per-pixel Alpha Channel
www.fengyuan.com/article/alphablend.html 

Animation See Animation Section of efg's Delphi Multimedia page

"Performing Animation with Graphics Programming," Delphi 5 Developer's Guide by Teixeira and Pacheco in Online "CD" Chapters, pp. 124-134

Restoring Animation:  Modifying Delphi Apps to Exhibit Standard Minimize and Restore Animation, Delphi Informant, March 1998

Antialiasing The algorithm is to draw a magnified line on a temporary, larger canvas and average the color over 4 or 9 nearest-neighbor pixels for a single new pixel.

Charles Haciker's UseNet Post about how to antialias a font

A unit to work with graphics. Many effects like: motion blur, alpha blending, antialiasing, text, texture mapping, save/load  from BMP/TGA.
http://delphi.icm.edu.pl/ftp/d30free/graph64.zip

SmoothText3D and SmoothText for Delphi 2/3
http://home.t-online.de/home/herbert.haas

Rough Around the Edges -- Antialiasing in Delphi by Rod Stephens, Delphi Informant, April 1998, pp. 60-64.

Borland Builder C++ Example
http://norfolkgraphics.com/download/antialias.zip

Toni Sanders' UseNet Post about how to turn off windows font anti-aliasing

Robin Green's post to comp.graphics.algorithms on 7 Oct 99:
Q:  Has anyone written antialiased text to a device independent bitmap in Windows 95/98 (with Font Smoother of Plus Pack installed)?
A: Select the font into the base window's DC then select it out and reselect it into your DIBSection.      Don't ask me why, that's just what you have to do. Also AA Text  in Windows messes up if your glyphs overlap -- no true alpha blending.  [Does anyone know how this might apply to Delphi?  --efg]

[Foley96, pp. 132-142, 617-647, 965-976]

Area PolygonArea.gif (957 bytes)   efg's Polygon Area and Centroid Lab Report
Arrows arrow.gif (1018 bytes)

Proportional Arrow or Fixed Head Arrow (with no trig!)
See examples of drawing an arrow from point (x1,y1) to (x2,y2) with the "tip" at (x2, y2).

Examples of flood-filled arrow heads ..
RotateAxes.gif (2571 bytes)
Rotation of arrows source code
(used in RotateScanline Lab Report)

"Eight Neighborhood" diagram source code

Kevan Booker's Arrow Example Project (click on the Demo button multiple times)

In Chapter 13 of  Mastering Delphi 5 (pp. 609-620), Marco Cantł shows how to create a TMdArrow component to draw arrows up, right, down or left.   In Chapter 16 Marco extends this example by "Building an ActiveX Arrow"  TMdWArrow.

D6 GraphUtil Unit:

procedure DrawArrow(ACanvas: TCanvas; Direction: TScrollDirection; Location: TPoint; Size: Integer); 

Draws a solid triangular arrow that can point in any TScrollDirection.  Also see Chevrons.

BitBlt (bit-block transfer) [Foley96, pp. 986-992]

Joe Hecht's UseNet Post with BltTBitmapAsDib procedure

Bitmaps Bitmap and Metafile Funtions, Tomes Graphical, p. 273-356

Also, see:
- "BMP" on File Formats and Conversion page
- "TBitmap" on VCLRTL page

Blobs Integer Blobs
www.daniel-davies.pwp.blueyonder.co.uk/programming/delphi/integer_blobs.htm 
Bresenham's line drawing algorithm efg's ColorLines example on Delphi Color Graphics Algorithms page:  Example of how to draw Gradient and Rainbow lines using TBresenham class in BresenhamLibrary unit.

Also see Lines below

G. Hoffmann's "Drawing Lines"
www.fho-emden.de/~hoffmann/drawf11102001.pdf 

Non-Delphi:

Bresenham Ellipse Algorithm
www.robots.ox.ac.uk/~awf/graphics/bres-ellipse.html 

Brushes Pens and Brushes, Tomes Graphical, p. 80

Also, see TBrush on VCLRTL page

Builder C++ Graphics Tips http://norfolkgraphics.com/bcb.php3 
Cartography see Maps
CGI

Picture This on the Web:  A CGI Program to Deliver Database Pictures, Delphi Informant, Feb 1998

Charts and Graphs See Delphi Graphics Components & Programs page

TChart Actions Building a No-code TChart Toolbar
www.delphiinformant.com/features/2000/04/di200004kw_f/di200004kw_f.asp 

"Using TeeChart," pp. 55-64;
"A Database Chart on the Web," pp. 65-67;
Chapter 22 (online "bonus" chapter) of  Mastering Delphi 5 by Marco Cantł.

efg's Lab Reports:
SimpleGraph.gif (1054 bytes)  Simple Graph
SimpleBarChart.gif (1026 bytes)  Simple Bar Chart

Checkmarks D6 GraphUtil Unit:

procedure DrawCheck(ACanvas: TCanvas; Location: TPoint; Size: Integer; Shadow: Boolean = True);

Draws checkmarks of any size at location with/out a shadow.

Chevrons D6 GraphUtil Unit:

procedure DrawChevron(ACanvas: TCanvas; Direction: TScrollDirection; Location: TPoint; Size: Integer); 

Draws arrows that look like ">" which can point in any TScrollDirection.  Also see Arrows.

Clipboard Mauro's UseNet Post about how to paste a bitmap to a TImage

Chapter 7, Using the Clipboard with graphics (pp. 7-20 - 7-22)
Borland's Delphi 5 Developer's Guide.

Bob Villiers' UseNet Post explaining how to store an icon on the clipboard
Peter Below's UseNet Post about no standard clipboard format for JPEGs

"Sharing Information with the Clipboard," Delphi 5 Developer's Guide, Chapter 17, by Teixeria and Pacheco

Bob Villiers' examples of copying JPEG in BLOB to clipboard, and JPEG file on clipboard to BLOB.  A separate demo shows how to store a user-defined image format (CF_JPEG) and  a predefined image format (DIB) simultaneously to the clipboard.

"A Simple Clipboard Viewer Component" by Grahame Marsh
www.undu.com/DN961101/00000012.htm

Copy bitmap to Clipboard (from Nick Hodges' UseNet Post):
If your TImage is a Bitmap, then use Clipboard.Assign(Image1.Picture.Bitmap)

Using the Clipboard with Images (pp. 550-551)
Creating Your Own Clipboard Format (pp. 551-552)
Creating a Clipboard-Aware Object (pp. 552-557)
Delphi 5 Developer's Guide by Teixeria and Pacheco

Clipping

Marching Ants 2 Professional Graphics Tools:  Clipping Areas
www.shrubware.com/category8_1.htm 

A common use for a Path or Region is to define a clipping region.  When a clipping region is defined and selected into a device context, any graphical output to the device context is confined within the boundaries of the region.
 VAR
   Region         :  hRGN;
...
  Region := CreateRectRgn(BevelThumbNail.Left,  BevelThumbNail.Top,
                          BevelThumbNail.Left + BevelThumbNail.Width,
                          BevelThumbNail.Top  + BevelThumbNail.Height);
  TRY
    SelectClipRgn(Canvas.Handle, Region);
...
    // Draw anything to be clipped here
...
    SelectClipRgn(Canvas.Handle, 0);  // Remove clipping restriction
  FINALLY
    DeleteObject(Region)
  END;

SelectClipRgn in efg's Printer Demo #2 Lab Report

TPictureClip extracts portions of a matrix of pictures and assign the "cell picture" to another picture control.  http://delphi.about.com/compute/delphi/library/weekly/aa022900a.htm

Sergey Prilutsky's "Using Clipping Regions for Faster GDI Drawing"

efg's TPantograph in Football, Sphere In Cube, or other Lab Reports
[Foley96, pp. 924-945]

Contouring

Non-Delphi:
CONREC: A Contouring Subroutine http://astronomy.swin.edu.au/~pbourke/projection/conrec/ 

Book: Contouring: A Guide to the analysis and display of spatial data, Vol. 10 in Computer methods in the geosciences, 1992.

Coordinate Systems Tomes Graphical, pp. 13-19

"Coordinate Systems and Mapping Modes," Delphi 5 Developer's Guide by Teixeira and Pacheco in Online "CD" Chapters, pp. 95-107

Counting Peaks efg's UseNet Post "Algorithm needed for counting peaks on chart"

efg's PixelProfile.gif (1269 bytes) Pixel Profile Lab Report

Cursors How to create and use a custom cursor.  efg's CustomCursor.TXT
efg's Cursor Overlay Lab Report
efg's ShowCursor example of displaying cursor at any position on screen 
(based on UseNet Post by Michael Winter)
How to Create BMP files for Standard Cursors:
procedure TForm1.ButtonFetchCursorClick(Sender: TObject);
  VAR
    Bitmap: TBitmap;
    hCursor: THandle;
begin
  Bitmap := TBitmap.Create;
  TRY
    Bitmap.Width := 32;
    Bitmap.Height := 32;
    Bitmap.PixelFormat := pf1bit;   // D3 or later (leave out in D2)

    // Use values of -1 .. -21 (or so) to cycle through all cursors
    hCursor := Screen.Cursors[ SpinEditIndex.Value ];

    DrawIconEx(Bitmap.Canvas.Handle, 0,0, hCursor, 32,32, 0,0, DI_NORMAL);

    Bitmap.SaveToFile('Cursor' + IntToStr(SpinEditIndex.Value) + '.BMP');
    Image.Picture.Graphic := Bitmap;

  FINALLY
    Bitmap.Free
  END
end;

The crXXX constants shown below are defined in the CONTROLS.PAS unit, e.g., crDefault = TCursor(0), crNone = TCursor(-1), crArrow = Cursor(-2), etc.

cursor-1.bmp (190 bytes)
-1
crNone
cursor-2.bmp (190 bytes)
-2
crArrow
cursor-3.bmp (190 bytes)
-3
crCross
cursor-4.bmp (190 bytes)
-4
crIBeam
cursor-5.bmp (190 bytes)
-5

crSize*
cursor-6.bmp (190 bytes)
-6
crSizeNESW
cursor-7.bmp (190 bytes)
-7
crSizeNS
cursor-8.bmp (190 bytes)
-8
crSizeNWSE
cursor-9.bmp (190 bytes)
-9
crSizeWE
Cursor-10.BMP (190 bytes)
-10
crUpArrow
Cursor-11.BMP (190 bytes)
-11
crHourGlass
Cursor-12.BMP (190 bytes)
-12
crDrag
Cursor-13.BMP (190 bytes)
-13
crNoDrop
Cursor-14.BMP (190 bytes)
-14
crHSplit
Cursor-15.BMP (190 bytes)
-15
crVSplit
Cursor-16.BMP (190 bytes)
-16
crMultiDrag
Cursor-17.BMP (190 bytes)
-17
crSQLWait
Cursor-18.BMP (190 bytes)
-18

crNo
Cursor-19.BMP (190 bytes)
-19

crAppStart
Cursor-20.BMP (190 bytes)
-20

crHelp
Cursor-21.BMP (190 bytes)
-21

crHandPoint
(D3)
Cursor-22.BMP (190 bytes)
-22

crSizeAll
(D4)
               

* In D4 and D5 the crSize cursor is defined the same as crSizeAll in Controls.PAS.  However, crSize still appears blank in my tests in D4 and D5.  In D2 and D3 , the crSize cursor is the same as crArrow.

In a UseNet Post by Anders Isaksson he says "according to my Delphi 2.01(?) source, the crSize is commented as {Dead cursors}, and the WIN32 help on Loadcursor says 'NT only' for IDC_SIZE (and 'Same as IDC_SIZE' for IDC_SIZEALL).  Starting D2 and checking, I don't even have the choice 'crSize' for cursors."  Justin Washtell  in an E-mail suggests a solution for this D2 problem with crSize.

Invalid cursor values, such as cursor -21 in D2 (which wasn't defined until D3), result in the crArrow cursor.

In the D1 documentation, the crCross cursor was shown to be more than one pixel "thick," but I have not verified D1 behavior.

efg's UseNet Post about difference between crHandPoint and IDC_HAND

To fetch the current cursor in the example above, use crDefault (0), i.e.:
   hCursor := Screen.Cursors[ ORD(Screen.Cursor) ];

To redfine "standard" cursors:
[Note:  I have observed that some cursor files don't work with this approach -- I don't know why.  I also don't know how to set crDefault with this approach.]
procedure TForm1.FormCreate(Sender: TObject);
begin
  // Set TForm1.Cursor to crArrow
  Screen.Cursors[crArrow] := // Large Arrow
  LoadCursorFromFile(pChar('M:\Windows\Cursors\Larrow.cur'));

  Screen.Cursors[crHourGlass] := // Large Hour Glass
  LoadCursorFromFile(pChar('M:\Windows\Cursors\Lwait.cur'));
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Screen.Cursor := crHourGlass;
  TRY
    Sleep(1500)
  FINALLY
    Screen.Cursor := crDefault
  END
end;

Icon, Cursor, and Caret Functions, Tomes Graphical, p. 357-402
Ray Lischner's UseNet Post about a better way to restore cursors automatically
Jens Gruschel's UseNet Post about what to do if the cursor change does not appear immediately
Philippe Bruno's E-Mail about changing cursor for a tray application
To turn cursors on or off, use
  ShowCursor(FALSE);
or
  ShowCursor(TRUE);

Normally use this construct (suggested by Jens Gruschel in newsgroup):

ShowCursor (FALSE);
TRY
   <anything here>
FINALLY
  ShowCursor (TRUE);
END;

Tip by Nigel Stratton in UseNet Post:
"Try placing an Application.ProcessMessages call after you change the cursor and before you do your intensive processing. It may be that the cursor doesn't get chance to change."
What's This?  Implementing a "What's This?" Help Toolbar Button
www.delphizine.com/features/1998/05/di199805dh_f/di199805dh_f.asp 
efg's Resource Demo application shows how to use the following file types in resource files:  BMP, ICO, JPG, GIF (requires Anders Melander's TGIFImage), EMF, TXT, AVI, WAV and cursors
Also see:
- Cursors on the Delphi Graphics File Formats and Conversion page
- TCursor on VCLRTL page
Cursors, Animated Neil Rubenking's PC Magazine (1 Nov 1999) Delphi utility CursorDance

How to use an animated cursor to your application
http://delphifaq.com/fq/q2077.shtml 

Cursors, Color Neil Rubenking's PC Magazine (1 Nov 1999) Delphi utility CursorDance
Curves and Surfaces [Foley96, Chapter 11, pp. 471-531]
Deskew TDeskewTransform is an addon component for Envision Image Library. The component allows to auto detect and correct the skew of an image. The skew is the little inclination who usually haves a scanned or faxed page. To deskew an image means to estimate and fix this imperfection.
http://delphi.icm.edu.pl/ftp/d50share/deskshar.zip 
Digits
Convert string of digits to BMP, JPG or GIF format, e.g., for a web counter.  LEDDigits.ZIP

In this case the number 123,456,789 was converted to a 1823-byte JPG and a 364-byte GIF file.

Requires TGIFImage from Anders Melander for GIF support.

Dissolve Chapter 8, Delphi 2 Multimedia, pp. 345-392.
Double Buffering Double Buffering -- Avoid the Flicker
www.richplum.co.uk/cbuilder/tutorials/graphics/bufferp1.asp?Lang=d

Anders Melander's UseNet Post about how to reduce flicker by using double buffering.

Douglas-Peucker Algorithm www.simdesign.nl/Components/DouglasPeucker.html 
Drag-and-Drop Antony Hoon's UseNet Post about drag and drop

Chapter 6, Working with Controls, Implementing drag-and-drop in controls
Borland's Delphi 5 Developer's Guide, pp. 6-1 - 6-4

Delphi drag and drop
www.ibrtses.com/delphi/ddragdrop.html

OLE Drag and Drop Applications
www.unitoops.com/uoole/examples

Delphi 4 Developer's Guide, pp. 6-1 - 6-7
Drag and Drop with Files (FAQ 529D)

Le Site Web de Michel (French)
http://perso.wanadoo.fr/bardou/michel/delphi.htm#lacheico.zip

Renate Schaaf's UseNet Post about "dirty rectangle" technique with images and postscript.

Dragging See MouseDown/MouseMove

Serge Gubenko's UseNet Post with TMyDragImageObject class to draw an object while dragging 

Drawing Borland example: ..\Delphi n\Demos\Doc\GraphEx.dpr

MetaDraw.   Sample drawing program.  Ddraw lines, circles.. and you still can change them (color, position...)
http://tothpaul.free.fr/usdelphi.htm#MTD

Quick on the Draw:  A Drawing Program Shows Off Delphi's RAD Abilities, Delphi Informant, Dec 1997

Painting and Drawing Functions, Tomes Graphical, pp. 79-193

Neil Rubenking's IconEdit32
www.zdnet.com/pcmag/stories/solutions/0,8224,2444578,00.html

"Drawing Shapes," pp. 6-14; "Printing Shapes," pp. 14-16
(Drawing Shapes: Line, Rectangle, Ellipse, RoundRect)
Chapter 22 (online "bonus" chapter) of  Mastering Delphi 5 by Marco Cantł.

Emboss effect www.hotfreeware.com/ftp/Pub/Source/sEmboss.pas 
File Formats See File Formats and Conversion page
Fire TFire draws a flame blazing in the window.
http://delphi.icm.edu.pl/ftp/d30free/tfire3.zip

Borland's Fire Contest Entries
http://homepages.borland.com/ccalvert/Contest/GameContestUpdate.html

Borland's Fire Contest Winners
http://homepages.borland.com/ccalvert/Contest/FlameWinners.html

Flicker Elimination Most flicker is caused by erasing the background (a Wm_EraseBkgnd message) of a control before painting it. The background color (often white) is usually very different from what you are painting, so the flicker becomes very obvious.

Flicker occurs with TImages when a bitmap is stretched (but apparently not when the bitmap is its "natural" size).  Avoid TImage flicker by making the TBitmap and the TImage the same size.  Sometimes TImage flicker can be reduced or eliminated by putting the TImage on a TPanel.  (This is an empirical  observation -- I don't know why it's true.)

To prevent a form from repainting its background every time it does a paint, which can cause flicker even when using the double buffering trick, put the following in the
     FormCreate: Form1.ControlStyle := Form1.ControlStyle + [csOpaque];
But while using csOpaque may seem desirable, it can also introduce problems with a dynamic TLabel.  See the LineCursors examples:  LineCursors.ZIP.  Note that when csOpaque is enabled, the (X,Y) values are not displayed correctly if they "grow" and then later "shrink."

Flicker-Free Graphics in Delphi!
www.undu.com/News/Articles/011126a.html 

See WM_ERASEBKGND info in efg's Win 32 API Messages.

Flickering images by Ing.Buero R.Tschaggelar

George Pistikos UseNet Post explaining problems with flickering in D6
George Pistikos' UseNet Post about "TImage bug in Delphi 6?"
Dana Skovsende's UseNet Post about a new problem with flickering in D6 and what to do about it

Anders Melander's UseNet Post about how to reduce flicker by using double buffering.
Wayne Sheffield's UseNet Post about using LockWindowUpdate to avoid flicker
The Patrician's UseNet Post about using GetUpdateRect to avoid flicker in redrawing a TImage
Peter Haas' UseNet Post about TImage flicker problems with animation

Invalidate, InvalidateRect, and Flicker:  If you invalidate a whole form, all TLabels will flicker when they're redrawn.  An alternative is to use InvalidateRect with the False parameter to stop this background erase.  Also, Validate/Invalidate can be used for some interesting effects.  efg's Invalidate project shows how Invalidate, InvalidateRect and ValidateRect work.

Avoiding flicker on drawcell (FAQ 1770D)
Prevent window update (FAQ 1349D)
Reducing flicker on component redraw (FAQ 1961D)

"Create memory DCs and BitBlt to the screen with BCB"
www.bcbdev.com/faqs/faq33.htm

"Eliminate flicker when painting on a form or a TPaintBox control"
www.bcbdev.com/faqs/faq34.htm

Sean Dockery's UseNet Post about "Repaint Paintbox without erasing background"

Flicker Free Animation and Sprites, Chapter 14, Delphi 2 Multimedia (out of print), pp. 625-674

This has worked in some cases for me:
InvalidateRect(SELF.Handle, NIL {whole window}, FALSE {don't erase background});
RedrawWindows(SELF.Handle, NIL, 0, RDW_UPDATENOW);

Flicker in Kylix graphics. RAPware has come up with a nice solution to the flickering of QT graphics.  Dr. Chris Rorden outlines the solution on this page::  www.psychology.nottingham.ac.uk/staff/cr1/kylix.html

Floodfill TCanvas.Floodfill:
     procedure FloodFill(X, Y:   Integer; Color:  TColor; FillStyle:  TFillStyle);
where FillStyle is fsBorder (area fills until a border of the specified color is reached) or fsSurface (area is filled as long as the specified color is encountered).

"Filling" algorithm
http://delphi.icm.edu.pl/ftp/d30free/fillunit.zip 

[Foley96, pp. 980-986]

Floodfill without a canvas
www.ibrtses.com/delphi/dff.html

Grassfire fill without a canvas
www.ibrtses.com/delphi/dgf.html

Floodfill example by Armindo DaSilva

Font Editor Non-Delphi:
In Visual Studio:  C:\Program Files\Microsoft Visual Studio\Common Tools\FontEdit.EXE
Fonts See Text below.
Full Screen Full Screen Example:  FullScreen.PAS.TXT
GDI Drawing Sergey Prilutsky's "Using Clipping Regions for Faster GDI Drawing"
Graphing Data See "Charts and Graphs" on efg's Delphi Graphics Components & Programs page
Graph, Network Delphi-component to show arrays of values as a netgraph. Hidden  lines, zoom/rotate/pan via mouse.
http://delphi.icm.edu.pl/ftp/d20free/graph3d.zip
Grids If you put an XY grid on a TBitmap and then display it in a TImage with Stretch  TRUE, then the grid lines are also stretched.  What's the alternative?  Keep an in-memory TBitmap "master" and StretchDraw it onto temporary TBitmap that is the same size as the TImage.   Draw the lines on the tempoary Bitmap and then display it in a TImage without Stretching.  See efg's StretchDemo D3/D4 project for complete details.   (StretchDemo contains a YelFlwr2Small.BMP for demonstrating this.)

"Graphical Grids" including a "Mines" game, pp. 44-55; "Printing Shapes," pp. 14-16
Chapter 22 (online "bonus" chapter) of  Mastering Delphi 5 by Marco Cantł.

Hints Writing an Infotip shell extension in Delphi
http://community.borland.com/article/0,1410,22987,00.html 

A HintBox just like the ones found in Lotus SmartSuite.
http://delphi.icm.edu.pl/ftp/c10free/hintbox.zip  

Dropping Hints, Delphi Informant
Part I: Taking Control of Fly-over Help, Dec. 1999
Part II:  A Hint Window Application, Jan 2000

Homogeneous Coordinates: Scaling, Rotation, Translation [Foley96, pp. 204-209]

efg's TPantograph in Football, Sphere In Cube, or other Lab Reports

Vivid Equations:  An Introduction to 3-D Graphics Programming, Delphi Informant, Aug 1998

Hotspots Using a Multiple Polygon Region as a hot spot. Tomes Graphical, pp. 214-216.
Defining Hotsponts on a Form, How to Program Delphi 3, pp. 115-117, 276-279.
Delphi 2 Multimedia (out of print), pp. 395-443.
THotImage component allows creation of "hot spots," i.e., active areas on an image.
http://delphi.icm.edu.pl/ftp/d20free/hotimage.zip
VMMap (Hot Map) Component 1.2 for Delphi Provides your Windows applications with ability to create a set of hot regions on image and connect mouse event handler to these regions. Image supports BMP format.  www.programmersheaven.com/zone2/cat71/14323.htm 
THyperImages: Hyperimaging component.Manage an unlimited number    of irregular shaped hotspots on multiple images. A visual Editor    lets you draw the hotspots creates a code template for you.
http://delphi.icm.edu.pl/ftp/d30share/hyperim3.exe
http://delphi.icm.edu.pl/ftp/d40share/hyperim4.zip  
http://delphi.icm.edu.pl/ftp/d30share/hypim200.zip
Icon Editor In Delphi IDE:  Tools | Image Editor
Icons Icon, Cursor, and Caret Functions, Tomes Graphical, p. 357-402

Also, see "ICO" on File Formats and Conversion page

Illumination and Shading [Foley96, Chapter 16, pp. 721-814]
Instrumentation See Instrumentation on Delphi Graphics Components and Programs page
Jigsaw
By Jean-Yves Quéinec

"Jigsaw Puzzle"

Lens Flare Lens Flare
www.daniel-davies.pwp.blueyonder.co.uk/programming/delphi/lens_flare.htm 

Lens Flare Tutorial (Builder C++ Example)
http://www.gamedev.net/reference/articles/article813.asp

Line Cursors efg's LineCursors examples:  LineCursors.ZIP.  Example 1 shows how to draw the cursors using XOR, while Example 2 shows how to draw the cursors on an in-memory bitmap with a specified color.  Both methods have strengths and weaknesses.
Lines Bresenham LineDrawing Algorithm

efg's ColorLines example on Delphi Color Graphics Algorithms page:  Example of how to draw Gradient and Rainbow lines using TBresenham class in BresenhamLibrary unit.

efg's Pascal code:  Bresenham.Txt adapted from Byte magazine, March 1988, pp. 249-253

Non-Delphi: Michael Abrash's Graphics Programming Black Book (out of print), Chapter35, "Bresenham Is Fast, and Fast is Good"

Dr. Jason Smithwick's E-mail  note with routine that draws thick lines with various pen styles
Drawing Dotted Line
Josef Garvi's UseNet Post "How to draw dot line and pen width more than one pixel"
Locating and Dragging a Line to a New Location
OnMouseDown, OnMouseMove, OnMouseUp, NearLine, Canvas.MoveTo, Canvas.LineTo

LineStretch.gif (928 bytes)   efg's Line Stetch Lab Report

How to Draw Marching Ants by Robert Vivrette. "Marching Ants"  (sometimes called a marquee rectangle) is essentially an animated rubber-banding line.
http://www.undu.com/DN960901/00000008.htm
Midpoint Line Algorithm, [Foley96, pp. 74-78]
Thick Lines:
- Gary Williams UseNet Post "Thick Dotted.Dashed Lines"
-  Josef Garvi's UseNet Post "How to draw dot line and pen width more than one pixel"
Line Styles:  LineDDA examples
Loading Graphic from Internet See UseNet Post by "Delphi_tip"
Magic Wand Magic Wand Tool.  The user selects a point of origin on an image. From there pixels within a color range set by a Tolerance level will be selected. This advanced tool is useful when complex selection areas have to be made of objects comprising of nearly the same color in an image. Likewise the same tool can be used to select a tolerance of colors within the whole image.  

Marching Ants 2 Professional Graphics Tools
www.shrubware.com/category8_1.htm 

Maps, Cartography Digital Elevation / Digital Terrain Programs
www.winsite.com/bin/Info?10500000036159 

Digital Elevation Models
www.ezl.com/~ilh2o 

Cartographic projection conversions
www.ecostats.com/software/softwaretools/softwaretools.htm 

Cartographic Projections Component
www.sigmap.com/04-JUL-2001.htm 

Cartographic projection conversions
www.ecostats.com/software/softwaretools/softwaretools.htm 

Map Projections
www.graticule.com/products/mapproject.html

TGlobe, www.tglobe.com 
Shareware version of TGlobe 4:  http://delphi.icm.edu.pl/ftp/d30share/tg403_d3.zip 

World Map Component serves many needs that may arise when an application wants to supplement its interface with a geographical display without the high costs associated with the GPS accurate map systems currently on the market.  www.programmersheaven.com/zone2/cat71/5848.htm 

Bull 3.0 Cartography
http://ibraent.ibrae.ac.ru/scripts/bull30/bullsrvr.exe/bull30?lang=eng&page=mdfdoc 

Building and displaying thematic maps
www.sigmap.com/tutorial/buildinganddisplayingthematicm.htm 

Marching Ants

Marching Ants Suite.  Marquee selection areas (or Marching Ants) are an integral feature of professional graphics programs such as Adobe Photoshop™ and Jasc Paint Shop Pro™. Users are able to select regions of different shapes with in a graphic to manipulate without effecting anything outside this region

Also see Rubber Banding.

Marquee, Image Example of scrolling in-memory TBitmaps as an image marquee
ImageMarquee.ZIP

Several Marquee Components
www.programmersheaven.com/zone2/cat502/index.htm 

Marquee Components at Torry's Delphi Pages
www.torry.net/marques.htm 

Marquee, Text efg's Text Marquee on Image example.  Manually move text over image with scrollbars, or enable "AutoMove" and change X and Y step sizes taken at each specified timer event.

Xavier Pacheco's UseNet Post with Marquee unit and Marquee control.

"The Marquee Component," Delphi 5 Developer's Guide (pp. 696-713) by Teixeria and Pacheco

Masks, Masking True Transparent Images With Masking by Robert Vivrette www.undu.com/DN970101/00000022.htm
Mouse SetCursorPos example of how to place the mouse cursor in the center of a button

Using OnHint for Real-Time Mouse Coordinates
www.undu.com/Articles/990618b.html

How to Restrict the Mouse
www.undu.com/DN960901/00000017.htm

Restrict Mouse area example in RestrictCursor.TXT

Real Time Mouse Coordinates Display
www.undu.com/Articles/990609c.html

How to detect mouse leaving a control? (CM_MOUSEENTER, CM_MOUSELEAVE)
Rick Rogers UseNet Post

ColorRange.gif (1115 bytes) efg's ColorRange Lab Report   (CM_MOUSEENTER, CM_MOUSELEAVE)

Beating The System: Delphi Meets IntelliMouse.  Dave Jewell has been playing with his fancy new wheel-equipped mouse and has found how to make your applications take full advantage of its features.
IntelliMouse and wm_MouseWheel, Delphi Magazine Issue 32 Free Disk, April 1998.  (After unzipping, look in the System directory, Unzip System32.ZIP, and look at the MouseDemo project) 

Dave Jewell wraps up his discussion of adding MS IntelliMouse support to your applications with a re-usable resource to make it ever so easy, plus clever code to IntelliMouse-enable the Delphi 3 IDE!   Delphi Magazine, Issue 33, May 1998

MouseDown, MouseMove, MouseUp
By Jean-Yves Quéinec. A graphic demo program, showing molecules in 3D. It's a Delphi adaptation of a Java JDK1.0 demo applet.   This routine uses scanlines and imagelists.   Move selected molecules in 3D space by clicking and dragging on the image. 
MoleculesA.ZIP

Claire Humphrey's UseNet Post with DrawFocusRect example

Also see Rubber Banding

MoveTo, LineTo Gary Williams' EnhancedBitmap, a descendent of TBitmap, for faster drawing of lines with MoveTo and LineTo.
Non-Rectangular Windows

Non-rectangular translucent forms in XP

FormShaper:  Say Good-bye to Rectangular Forms
www.delphiinformant.com/features/2000/03/di200003pm_f/di200003pm_f.asp

Classic Delphi:  Windows Region Example -- A form shaped like a "T"
www.govst.edu/users/gsmpati/delphi 

The "W" Window
www.richplum.co.uk/cbuilder/tutorials/winapi/weirdwind.asp

Weird Delphi
http://delphi.about.com/compute/delphi/library/weekly/aa120898.htm

Gruhn' Transparent Delphi App
www.hwb.com/gruhn/programming/tutorial/clear.html

How to Make a Polygonal Splash Screen by Michael Barnes www.undu.com/DN970101/00000006.htm

Non-Rectangular Windows by Robert Vivrette
www.undu.com/DN961001/00000007.htm

Foneword32 -- make words from phone numbers
www.zdnet.com/pcmag/pctech/content/16/18/ut1618.001.html

How to make a triangular form
Dudįs József's  UseNet Post

Nova Super nova effect, www.hotfreeware.com/ftp/Pub/Source/sNova.pas 
Odometer Simulation of an odometer. It can be configured to display cardinal decimal, hexadecimal, or binary values. It optionally animates the rolling of the digits.
http://delphi.icm.edu.pl/ftp/d20free/odomt101.zip
Optimization

For some general optimization tips, see Optimization on efg's Delphi Miscellany page

Painting Painting and Drawing Functions, Tomes Graphical, pp. 79-193

"Creating a Paint Program," Delphi 5 Developer's Guide by Teixeira and Pacheco in Online "CD" Chapters, pp. 108-124

Painting a form's background with a pattern pp. 17-23, Delphi Programming Problem Solver, Neil Rubenking
Paths Region and Path Functions, Tomes Graphical, pp. 195-270

Regions and paths are not encapsulated by the Delphi VCL.  (See Regions below)

A path is a shape definitinon created using a series of GDI drawing functions -- a path need not be a closed polygonal shape.  The drawing functions between a BeginPath and EndPath call will not produce output to the screen, but define the shape of a path.

A path is associated with the device context in which it is defined.  Only one path can exist in a device context at a time.  A path can be converted to a region using the PathToRegion function.  The GetPath function returns an array of TPoint structures containing the coordinates defining the path in logical units.

Pens Pens and Brushes, Tomes Graphical, p. 80

Also, see TPen on VCLRTL page

Pie Slice efg's DrawPieSlice draws a pie slice given start and stop angles [in degrees] on a specified canvas:
PROCEDURE DrawPieSlice(CONST Canvas:  TCanvas;
                       CONST Center:  TPoint;
                       CONST Radius:  INTEGER;
                       CONST StartDegrees, StopDegrees:  Double);
Print Image efg's Printing Info & Links page
Printing efg's Printing Info & Links page
Projections, 3D-to-2D efg's TPantograph in Football, Sphere In Cube, or other Lab Reports
[Foley96, pp. 230-281]
Regions Region and Path Functions, Tomes Graphical, pp. 195-270

Regions and paths are not encapsulated by the Delphi VCL.  (See Paths above)

A region is a closed, polygonal shape that can be rendered with various techniques.   Regions tend to be be simpler in shape than paths.  Regions can be combined in various ways to produce more complex shapes.  A region can be used for hit testing, such as a "hot spot," using the PtInRegion function.  Any number of regions can be created.

Manipulating Regions with Delphi by Don Monroe
www.undu.com/DN961001/00000016.htm

Complex Window Regions
www.undu.com/Articles/990114c.html

More Regions!  (Text as Image)
www.undu.com/Articles/990128c.html

See various region functions on Graphical API page

CreateRectRgn, CreateEllipticRgn, CombineRgn, SelectClipRgn
efg's
Printer Demo #2 Lab Report

Resizing Forms TI944D, Form display with different screen resolutions
http://community.borland.com/article/0,1410,15944,00.html 

Dick Claessens' UseNet Post to switch on the resizing rectangle

ResizerPanel.  Want your Forms to work in any graphic resolution?
This component automatically adjusts all child controls size proportionally to the panel current size. Including font size, column widths, etc...  With this you can easily deploy graphic resolution independent applications.  ftp://carlos.123webhosting.net/pub/resizer.zip

Resource Files Add an .rc file to your project and Delphi will compile it automatically into a .res.

efg's Resource Demo application shows how to use the following file types in resource files:  BMP, ICO, JPG, GIF (requires Anders Melander's TGIFImage), EMF, TXT, AVI, WAV, cursors, and a matrix of binary data (Integers and Doubles).  Requires D4 (or above) for the dynamic array of binary data.

efg's RichEditResourceInit example for initializing TRichEdit from .RTF in resource file.

An example of Neil Rubenking's trick to use a ResMake.BAT file to create a .RES file.

Cursors in Resource Files.  See Discussion section of efg's Cursor Overlay Lab Report.

Ken White's UseNet Post about imbedding an AVI in a resource file

PE Resource Editor s a free Resource Editor written in Delphi 6.  It allows you to explorer and edit resources both in .RES files windows modules - .EXE, .DLL, etc.  www.wilsonc.demon.co.uk/d6peresourceeditor.htm 

Resource Usage Sample Application v1.0 Borland Delphi 4 Sample application including step-by-step description of the usage of a variety of resource types, such as; AVI, Bitmap, Text and a custom defined resource.  www.programmersheaven.com/zone2/cat262/16821.htm 

Peter Haas' UseNet Post about using rc file directly in Delphi project (D5 or later)

Ralph Friedman's UseNet Post about  how to play a WAV in a resource file
Ralph Friedman's UseNet Post about how to create a .RES with wave files

Bob Villiers' UseNet Post about how to store a 24-bit .BMP in a resource file

Resource Functions, Tomes Graphical, pp. 561-585

Loading Cursors from a Resource file. efg's CustomCursor.TXT

Loading a Bitmap from a Resource file.  efg's BitmapInResource.TXT

Converting 16bit resource to 32bit (FAQ 2510D)
Creating a resource only DLL (FAQ 1595D)
Creating resource files (FAQ 2514D)
How to use a user defined resource (TI 1537D)
Storing icons in your application for use at runtime? (FAQ 2767D)
Linking an animated cursor to a resource file (FAQ 2841D)
Loading Bitmaps and Cursors from RES files (TI 1081D)

Building Resource-Only DLLs in Delphi
www.undu.com/DN960501/00000008.htm 

Neil Rubenking's AniCurFromResource in the AllFuncs.pas unit of his ColorClue utility.

Load bitmaps and icons from the program's resources
www.bcbdev.com/faqs/faq53.htm

Load Bitmap Resource by Ray Lischner.
Look for bmpres10.zip www.tempest-sw.com/freeware
or via ftp at ftp://ftp.tempest-sw.com/pub/delphi/bmpres10.zip

LoadFromResourceName

Image Conflicts between different versions of IE (FAQ 1846D)

How to Make a Polygonal Splash Screen by Michael Barnes www.undu.com/DN970101/00000006.htm

The second parameter MUST BE IN UPPER CASE, e.g.:
AllDigits.LoadFromResourceName(hInstance, 'LEDDIGITS'); 

The first parameter is the global variable hInstance.

procedure GetGlyphResource
     (const SpeedButton: TSpeedButton; const name: string);
  var
    bitmap: TBitmap;
begin
  bitmap := TBitmap.Create;
  try
    bitmap.LoadFromResourceName(hInstance, name);
    Speedbutton.Glyph := bitmap
  finally
    bitmap.Free
  end
end; {GetGlyphResource}

Resource Hacker has been designed to:
- View resources in Win32 executable and related files (*.exe, *.dll, *.cpl, *.ocx) in both compiled and decompiled formats; 
-Extract (save) resources to file in: *.res format; as a binary; or as decompiled resource scripts or images. Icons, bitmaps, cursors, menus, dialogs, string tables, message tables, accelerators, Borland forms and version info resources can be fully decompiled into their respective formats, whether as image files or *.rc text files.
http://www.rpi.net.au/~ajohnson/resourcehacker 

Rotation, bitmap See "Bitmap Rotation" in  Image Processing.
Rotation, math Vivid Equations:  An Introduction to 3-D Graphics Programming, Delphi Informant, Aug 1998
Rotation, text How can I display a rotated font?  How can I print a rotated font?

See "Related" Section of Circle Word Wrap Lab Report

Rotation, vector Rotation of (vector) arrows or axes:  RotateAxes.ZIP

See a diagram and the math for vector rotation as part of efg's Rotate Scanline Lab Report

Rubber Banding Chapter 7, Rubber Banding Example (pp. 7-22 - 7-27)
Borland's Delphi 5 Developer's Guide.

Robert Vivrette's How to Draw a Rubber-Banding Line
www.undu.com/DN960901/00000007.htm

How to Draw Marching Ants by Robert Vivrette. "Marching Ants"  (sometimes called a marquee rectangle) is essentially an animated rubber-banding line.
http://www.undu.com/DN960901/00000008.htm

Rubber Banding
http://bcbcaq.freeservers.com/rubber_band.html

Renate Schaaf's UseNet Post with example code

Wayne Sherman's UseNet Post with more efficient technique:  "On mouse move, we BLT only a section of the bitmap needed to erase our rubberband line, back to the forms canvas, then we draw the line to the form canvas.  This reduces flicker of thick lines except for long diagonals.  On mouse up, we BLT the original bitmap back to the form canvas to make sure everything is cleaned up."

efg's sample project of how to use "Marching Ants" over a TImage

LineStretch.gif (928 bytes)   efg's Line Stretch Lab Report

David Lively's UseNet Post about controlling XOR color if background is not too complex

efg's LineCursors examples:  LineCursors.ZIP.  Example 1 shows how to draw the cursors using XOR, while Example 2 shows how to draw the cursors on an in-memory bitmap with a specified color.  Both methods have strengths and weaknesses.

[Foley96, pp. 382-385]

Screen Capture Links about Screen Capture involving printing
Runtime Keystrokes links about Screen Capture

Charles Hacker's UseNet Posting about "How to print a window with Delphi?"

Serge Gubenko's ZoomOutSources that captures and enlarges an area of the Windows desktop. Works similar to ZoomIn utility from Visual Studio, but has more functionality, such as drawing grid lines.

Peter Below's UseNet Post with SaveScreenImageToFile procedure
ZeppinHood's (aka Joe Hecht) UseNet Post with ScreenShot procedure
Kerstin Thaler's UseNet Post with example of capturing client area or whole screen
Screen Capture, www.xploiter.com/programming/delphi/tips3.shtml#tip25

Blocking Screen Capture

type
TFormSlideShow = class(TForm)
...
private
...

PROCEDURE ApplicationIdle(Sender: TObject; var Done: Boolean);
public
...
end;
...
implementation
{$R *.DFM}

...
USES
  ClipBrd;

// Don't allow screen capture by deleting anything on clipboard when
// PrintScreen key is pressed.
//
// See Borland FAQ930D, Detecting if the PrintScreen key has been pressed
// http://community.borland.com/article/0,1410,15930,00.html
PROCEDURE TFormSlideShow.ApplicationIdle(Sender: TObject; var Done: Boolean);
BEGIN
  // Get rid of anything on clipboard
  IF   GetAsyncKeyState(VK_SNAPSHOT) <> 0
  THEN ClipBoard.Clear;

  Done := True;
END {ApplicationIdle};

procedure TFormSlideShow.FormCreate(Sender: TObject);
begin
  Application.OnIdle := ApplicationIdle;
...
end;

Non-Delphi:
Window Contents Capturing using WM_PRINT Message
www.fengyuan.com/article/wmprint.html 
Screen Resolution Displays all your monitor's resolutions & allows you to change them programatically.
www.xploiter.com/programming/delphi/files/resolutions.zip
PROCEDURE GetScreenResolution(VAR iPixels, jPixels: INTEGER);
  VAR
    DeviceContext: hDC;
BEGIN
  // Get the screen's DC since memory DCs are not reliable
  DeviceContext := GetDC(hWnd_DeskTop);

  TRY
    iPixels := GetDeviceCaps(DeviceContext, HORZRES);
    jPixels := GetDeviceCaps(DeviceContext, VERTRES)
  FINALLY
    // Give back the screen DC
    ReleaseDC(0, DeviceContext)
  END
END {GetScreenResolution};
Screen Savers Random Images Screen Saver in Delphi
http://community.borland.com/article/0,1410,26652,00.html 

Neil Rubenking's ScreenPhaser in PC Magazine, Sept . 2000

How to write Windows 95 Screen Savers
www.avdf.com/oct97/art_d001.html

Advertising ScreenSaver
http://inner-smile.com/dl_adv.htm

Creating your own screen saver, Delphi Developer's Journal, Feb. 1998, pp. 4-10.
ftp.zdjournals.com/ddj/98FEB/DDJ9824.ZIP

How to Write a 32Bit Screen Saver
www.wischik.com/scr
www.wischik.com/scr/howtoscr.html

Component to create easy Screensavers for Windows 95 & NT in Delphi.
http://delphi.icm.edu.pl/ftp/d30free/scrnsvr3.zip

Turning on Screen saver with code (FAQ 2450D)
Turning the screen saver off (FAQ 1259D)
Creating a 32-Bit Screen Saver in 32-bit Delphi (TI 4534D)

No screen savers for me please
www.chami.com/tips/delphi/121196D.html 

Chapter 8, "Animated Screen Savers in Delphi" in Kick Ass Delphi Programming (out of print)

Scrolling "Scrolling" on Image Processing page
ScrollWindowEx // Put a TImage on a form and then click this button
procedure TForm1.Button1Click(Sender: TObject);
  VAR R:  TRect;
begin
  R:=Form1.ClientRect;
  ScrollWindowEx(Form1.Handle,
                 5 {pixels right},5 {pixels down},
                 @R,@R,0,nil,SW_INVALIDATE);
end;
Selection Tools Marching Ants 2 Professional Graphics Tools

Selection Tools:  Point-to-Point Tool, FreeHand Tool, Complex Region Tool
www.shrubware.com/category8_1.htm 

Also see Magic Wand

Semi-transparent forms GlassyForm
www.torry.ru/vcl/forms/effects/glassy.zip

StainedGlass
www.torry.ru/vcl/forms/effects/stainedglass.zip

Neil Rubenking's UseNet Post with an example

Shapes

Gordon Whittam's UseNet Post with DrawBullet procedure for drawing a bullet using PolyBezier API call.  I tested Gordon's routine with this :

procedure TForm1.Button1Click(Sender: TObject); 
begin 
  DrawBullet(Canvas, Point(Top,Left), Point(Height, Width DIV 2), 400) 
end;

Solid Modeling [Foley96, Chapter 12, pp. 533-562]
Snap to grid www.ibrtses.com/delphi/snap.html
Splash Screen

How to Make a Polygonal Splash Screen by Michael Barnes www.undu.com/DN970101/00000006.htm

Creating a Splash Screen
www.undu.com/DN960901/00000013.htm

Creating a Splash Screen with a Delay
www.undu.com/DN960901/00000014.htm

Splines [Foley96, pp. 1013-1018]
Sprites Sprite animation
www.delphiforfun.org/Programs/Delphi_Techniques/animation.htm 

By Jean-Yves Quéinec.  The Sprites unit provides a tool for complex and smooth animated scenes on a standard Windows canvas (Tpaintbox.canvas or Tform.canvas). The actual version uses Delphi 3 release or greater. (A Delphi1 version is also available.)  The sample program is a wonderful animation of the News Years 2001 fireworks in Paris, as well as a surprise effect with the Eiffel tower.    Be sure to start with the SprHelp.HLP file.  FirevewA.zip   Also see Jean-Yves' jigsaw puzzle.

Sprites Components
www.programmersheaven.com/zone2/cat499/index.htm 

"Performing Animation with Graphics Programming," Delphi 5 Developer's Guide by Teixeira and Pacheco in Online "CD" Chapters, pp. 124-134

A Quick and Dirty VCL Sprite Engine (Builder C++)
http://community.borland.com/article/0,1410,20732,00.html

Sprite Engine for Delphi
www.delphi32.com/vcl/614 

TurboSprite for Delphi 4
www.silicmdr.com/TurboSprite.htm

Dragging a Sprite, pp. 323-326, Delphi Programming Problem Solver (out of print), Neil Rubenking

Flicker Free Animation and Sprites, Chapter 14, Delphi 2 Multimedia (out of print), pp. 625-674

Star TShape descendant that has a star shape and has OnMouseEnter/Leave handlers
Eddie Shipman's UseNet Post

Alan Lloyd's UseNet Post about a Christmas Star drawn with a DrawPentacle procedure

Starfield example www.multimania.com/tothpaul/zip/STARS.ZIP 
StringGrid Example of how to use a string grid to display a matrix of ICOs, and optionally, the name of the ICO
IconMapDemo.ZIP
SWAG Graphics  SWAG (Software Archive Group):  292 graphics examples
www.gdsoft.com/swag/graphics.zip   (requires Reader)
Regions Region and Path Functions, Tomes Graphical, pp. 195-270
Terrain rendering GLScene -- OpenGL Solution for Delphi
http://glscene.cjb.net 
Text Use a brush style of bsClear to write text with a transparent background.

Alex Weidauer's UseNet Post about how to draw symbols along a polygon line

"Advanced Fonts," Delphi 5 Developer's Guide by Teixeira and Pacheco in Online "CD" Chapters, pp. 134-150

Text Functions, Tomes Graphical, pp. 459-558

Add Print Preview to Your Applications
www.undu.com/Articles/000207f.html

Steve Schafer's UseNet Post about WYSIWYG text and Windows API Functions

TScrollingCredits is a component which displays scrolling credits like those at the end of movies, videos, etc.  http://delphi.icm.edu.pl/ftp/d20free/credits.zip 

What's the easiest way to implement word wrap?
Use the DrawText or DrawTextEx Win API call.

CircleA.gif (989 bytes)  efg's Circle Word Wrap Lab Report including "Related" section

Jon T. Camp's UseNet Post about filling text with a bitmap

Peter Below's UseNet Post about how to get the Windows title font (and information about TNonClientMetrics)

Philipp Crocoll's UseNet Post with "Star Wars Text" example
Harm's UseNet Post with "Star Wars Text" example by Philipp Crocoll

Finn Tolderlund's UseNet Post about Transparent desktop icon text

Function DrawHTMLText to draw formatted text to a canvas
www.qtools.com/dev/DrawHTMLText.zip 

Text, Contrast User interface contrast "rule":  Use dark text on light backgrounds and light text on dark backgrounds.

Andreas Filsinger's VisibleContrast function for creating text with good contrast with the background.

Text, Alignment Text Alignment in a StringGrid OnDrawCell

Right-Justified

Dr. Bob's Tip-of-the-Hat:  Right-Aligned T42Edit

How to Right Justify Text in a TEdit
www.undu.com/Articles/000207c.html

Text, Rotated How can I display a rotated font?
How can I print a rotated font?

Fancy Menus, etc.:  Custom Menus, Rotated Text, and Special Lines
www.delphizine.com/features/2000/12/di200012bs_f/di200012bs_f.asp

Adding vertical text and a color bar to a popup menu
http://community.borland.com/article/0,1410,26632,00.html 

Jacques Oberto's Wrapping Text Around a Circle Project
Walter Schick's Circle Word Wrap Project
Walter Schick's Rotated Text Project

"Rotating Text," pp. 71-72, Chapter 22 (online "bonus" chapter) of  Mastering Delphi 5 by Marco Cantł.

Text, Shadowed Dr. Bob's Tip-of-the-Hat:  Shading T42Label

Eddie Shipman's UseNet Post with sample of how to create Outline/Shadow Text using bsClear
Toni Sander's UseNet Post with an alternative to create Outline/Shadow Text

procedure TForm1.Button1Click(Sender: TObject);
  VAR
    Bitmap:  TBitmap;
begin
  Bitmap := TBitmap.Create;
  TRY
    Bitmap.PixelFormat := pf24bit;

    Bitmap.Width := 125;
    Bitmap.Height := 50;
    Bitmap.Canvas.Brush.Color := clSilver;
    Bitmap.Canvas.FillRect(Bitmap.Canvas.ClipRect);

    Bitmap.Canvas.Brush.Style := bsClear;

    Bitmap.Canvas.Font.Height := 36;
    Bitmap.Canvas.Font.Name := 'Arial';

    Bitmap.Canvas.Font.Color := clBlack;
    Bitmap.Canvas.TextOut(5,5, 'Shadow');

    Bitmap.Canvas.Font.Color := clWhite;
    Bitmap.Canvas.TextOut(7,7, 'Shadow');

    Bitmap.SaveToFile('Shadow.BMP');

    Image1.Picture.Graphic := Bitmap;
  FINALLY
    Bitmap.Free
  END
end;

Text, Stroke Path

// Based on newsgroup suggestion by Gordon Whittam
// 21 Nov 2001
procedure TForm1.Button1Click(Sender: TObject);
  VAR
    Bitmap: TBitmap;
begin
  Bitmap := TBitmap.Create;
  TRY
    Bitmap.Width := 300;
    Bitmap.Height := 120;
    Bitmap.PixelFormat := pf24bit;

    Bitmap.Canvas.Font.Name:= 'ComicSans MS';
    Bitmap.Canvas.Font.Size:= 40;

    Bitmap.Canvas.Brush.Style:= bsClear;
    BeginPath(Bitmap.Canvas.Handle);
    Bitmap.Canvas.TextOut(10, 5, 'Hello World');
    EndPath(Bitmap.Canvas.Handle);
    StrokePath(Bitmap.Canvas.Handle);

    Bitmap.Canvas.Brush.Style:= bsDiagCross;
    Bitmap.Canvas.Brush.Color := clBlue;
    BeginPath(Bitmap.Canvas.Handle);
    Bitmap.Canvas.TextOut(10,50, 'Hello World');
    EndPath(Bitmap.Canvas.Handle);
    StrokeAndFillPath(Bitmap.Canvas.Handle) ;
  FINALLY
    Image.Picture.Graphic := Bitmap
  END
end; 

Texture Mapping A unit to work with graphics. Many effects like: motion blur, alpha blending, antialiasing, text, texture mapping, save/load  from BMP/TGA.
http://delphi.icm.edu.pl/ftp/d30free/graph64.zip
Threads and Graphics "Multithreaded Graphics," Delphi 5 Developer's Guide (pp. 330-334) by Teixeria and Pacheco

Thread Sorting Demo
Borland example: ..\Delphi n\Demos\Threads\ThrdDemo.DPR

Threads and Graphics and Response
Per Dalgas Jakobsen's UseNet Post

For some general thread tips, see Threads on efg's Delphi Miscellany page

Tiling How to paint the form with a bitmap 
http://community.borland.com/article/0,1410,15551,00.html 

Brush Bitmaps Lab Report 
Feathering" Lab Report

Transformation, Affine and Projective Example code by Lazikas o Pontios for Intergraph Irasc files.
Transition Effects TTransitionFX component displays transition effects. This version supports the following effects: Push, Blinds, Checkerboard, Crush, MonoReveal, Reveal, Iris, Strips, MonoSlider, Slider, Zoom, Fade, Mosaic, Blend, Glide, Replace.
www.fortunecity.com/skyscraper/download/125/delphi.html#TTransitionFX  

Graphic/animation component that will transition from one TPicture to another TPicture.   It will do either a blend or a dissolve transition.   It is easy to use, just assign pictures like you would for a TImage, and in your code use the HarmFade.Blend or HarmFade.Dissolve method to start the effect.  It's also sometimes called a 'tweener. 
http://delphi.icm.edu.pl/ftp/d30free/harmfade.zip

FormContainer & Transition Effects
www.billeniumsoft.com/features.htm 

TPicShow is an image slider with 127 transitional effects. Some features of this component are: Can use a separated thread for its process Has a background image property with ability to show background image as tiled, stretched or centered Can center or stretch image into its client Animates without flickering Smart frame timing Can be controled manually Easy to add new effects Pure Delphi code Data-aware version and demo are included. 
http://delphi.icm.edu.pl/ftp/d30free/picshow.zip  

Translation Vivid Equations:  An Introduction to 3-D Graphics Programming, Delphi Informant, Aug 1998
Transparency TBitmap defines a transparency color as being the color of the pixel in the lower-left corner. 

Text with transparent background: Use Brush.Style := bsClear when writing text with a transparent background.

Transparency in Delphi 6
http://delphi.about.com/library/weekly/aa022202a.htm 

Transparent Forms in Delphi 5 and 6
www.howtodothings.com/showarticle.asp?article=434 

Henrik Palmér's UseNet Post about a transparency solution using BitBlt twice

Example component that allows you to create semi-transparent window in Windows 2000.  An Alpha value of 128 looks good (255 is a normal opaque window).  By Paul Mason.

Ignacio Alvarez's UseNet Post with modified  TransparentStretchBlt function

DBTransparentImage:   A simple descendant of TDBImage with one extra property: Transparent.
www.djpate.freeserve.co.uk/DBTImage.zip

Gruhn's Transparent Delphi App
www.hwb.com/gruhn/programming/tutorial/clear.html

True Transparent Images With Masking by Robert Vivrette www.undu.com/DN970101/00000022.htm

True Transparency with TBitmaps
http://bcbcaq.freeservers.com/project_DR.html

Danny Thorpe's UseNet Post about why transparency often fails on paletted devices

Shannon Broskie's UseNet Post with DrawTitleBarImage function

Transparent property to work for a CoolBar background bitmap (FAQ1390D)
Drawing transparent text onto a TBitmap (FAQ 2079D)
Dynamically drawing a transparent image (FAQ 1794D)
How can I create a transparent form?  (FAQ 1520D)
Keeping a glyph's transparent area transparent (FAQ 1385D)
Setting a transparent background color for TImageList (FAQ 2346D)

Sean Dockery's UseNet Post about Transparency including links to Microsoft Technical Reports

Bill Zissimopoulos' UseNet Post about how copy the area behind a component

TTransparentMemo in UseNet Post by Benjamin

Transparent Button: How to Program Delphi 3 (out of print), pp. 290-292.

TransparentButton.gif (1089 bytes)  efg's Transparent Buttons on an Image Lab Report

See Delphi Printing Info and Links (Item 11) for information about Transparency and printing.

Vector Graphics Simple Vector Library
http://sourceforge.net/projects/svl 
Video efg's Delphi Graphics Multimedia page

Delphi example of DirectX Video with EPIX PIXCI Card

Visible Surface Determination Non-Delphi: Michael Abrash's Graphics Programming Black Book (out of print), Chapter 64, "Quake's Visible-Surface Determination"

[Foley96, pp. Chapter 15, pp. 649-720]

Wallpaper Daniel's Usenet Post about drawing directly on wallpaper

How to change the wallpaper of your desktop?
www.delphigalaxy.bizland.com/tips/t10.html 

Ignacio Alvarez's UseNet Post about changing wallpaper

Creating a Wallpaper Using Delphi (TI 1351D)
Changing the Windows wallpaper in code (FAQ 2607D)
How do I set the Wallpaper on Windows98/2000 when ActiveDesktop is turned on?  (FAQ 4661D)

Setting the wallpaper (titled, center, stretched, positioned)
http://members.xoom.com/_XMCM/jescott/DelphiCodeTips3.html#SetWallpaperExt

Setting Windows wallpaper
www.chami.com/tips/delphi/123096D.html

Harm's UseNet Post about Using a JPG for Wallpaper
Loki's UseNet Post about Wallpaper Refreshing

Waves See Algorithms page
Web Graphics WebBroker Images
www.drbob42.com/delphi5/examin11.htm 

Brian Slack's UseNet Post about ISAPI graphics and TChart

Wind effect www.hotfreeware.com/sourcecode.htm 
Window Movement Window Movement Functions,  Tomes Graphical, pp. 587-618
Window-to-Viewport Transformation [Foley96, pp. 210-212]
World-to-Screen Mapping See Axes on Delphi Graphics Math page
See Graphics Math on Delphi Graphics Math page

TMathImage.  A TGraphicControl descendant which allows drawing in world coordinates. Both 2-D and 3-D graphs are supported. Surfaces can be drawn filled with hidden invisible parts and with a simple light source. Can be saved as bmp or emf-files. New: Much improved drawing speed, especially for surfaces.
www.xmission.com/~renates/delphi.html

Mapping world and screen
www.ibrtses.com/delphi/dmcs.html

ksupaw.jpg (1358 bytes) efg's TPantograph in Lab Reports:
Football   or   Sphere In Cube

Suggestion by CC.Campbell for using
TextOut with TPantograph

Chromaticity.gif (2862 bytes) MapWorldToPixel unit in "Simple Pantograph"
efg's Chromaticity Lab Report
XOR Effect
Mark Q's UseNet Post with interesting XOR effect using pointers, TBitmapInfo and StretchDIBits.

See efg's UseNet Post reply and complete project  showing Mark Q's XOR effect but using a simpler Scanline method  (D3-D6 project)

See UseNet Posts with suggestion one and suggestion two from Stan.

See gradient effect suggested by Paul Nicholls


Note:
   Foley96 (referenced above in several places) is not a Delphi book,
but is an excellent source for computer graphics algorithms.


Links Verified 11 Sep 2004
Updated 26 Feb 2005


since 1 Nov 1998