Are you never displaying the TImage
? Then you should really use an off-screen bitmap instead. This is a very common technique to achieve double buffering (flicker-free rendering).
For example,
var
bm: TBitmap;
procedure InitOffscreenBitmap;
begin
bm := TBitmap.Create;
bm.SetSize(bmWidth, bmHeight);
end;
procedure DrawBitmap;
begin
// Draw on bm
end;
procedure Swap;
begin
BitBlt(Canvas.Handle, X, Y, bmWidth, bmHeight, bm.Canvas.Handle, 0, 0, SRCCOPY)
end;
If you are using a modern version of Windows (e.g. Vista+), or Windows XP with ClearType enabled (for some very odd reason, it is disabled by default), text should be smooth. Just make sure that you use a modern font. Most of them will do, but very old fonts such as MS Sans Serif cannot be smoothed using ClearType.
Also, naturally, it is imperative that bm
has the same background colour as the form, because alpha-blending will occur when the text is drawn on bm
. So if the form is clRed
(for some perverse reason), you need to do
bm.Canvas.Brush.Color := clRed;
bm.Canvas.Brush.Style := bsSolid;
bm.FillRect(Rect(0, 0, bmWidth, bmHeight));
prior to
bm.TextOut(...)
Just so we are talking about the same thing: Isn't this smooth enough?
procedure TForm3.FormPaint(Sender: TObject);
begin
Canvas.Font.Name := 'Segoe UI';
Canvas.Font.Height := 64;
Canvas.TextOut(10, 10, 'This is an example.');
end;

(High-Res)