[Lazarus] Fastest way to draw

Duncan Parsons D.Parsons at seamsltd.com
Mon May 24 13:08:46 CEST 2010


Oh, that's good to hear - I'll bare it in mind next time I'm doing
similar things. I've generally used other libs as I've needed alpha
blending of images, but you tend to forget the easy things when you've
had more challenging requirements!

[apologies for topposting!]
DSP

-----Original Message-----
From: Brad Campbell [mailto:brad at wasp.net.au] 
Sent: 23 May 2010 11:47
To: Lazarus mailing list
Subject: Re: [Lazarus] Fastest way to draw

Mattias Gaertner wrote:
>>
>> There has to be a faster way to get data to the screen in a 
>> cross-platform fashion (I'm developing on Linux but ultimately I'll
be compiled for OSX and Win32).
> 
> Paint onto a memory image and then draw that.
> 
> As memory image you can use TBitmap which has comfortable fonts, but 
> is not the fastest.
> 

So, taking into account your comment "is not the fastest" I thought I'd
give a plain TBitmap a try. 
It's by _far_ the fastest I've tried yet. So fast in fact that I really
can't time it using Millisecondsbetween(). Amazing.

I have 2 TBitmaps assigned globally. One I pre-prepare with my
background (stuff, graticule and other lines) every time there is a
resize.

In the OnPaint() handler I copy the contents of the background TBitmap
to the foreground TBitmap, then draw a couple of thousand lines on it
before copying it to the canvas of a panel (I'm using a TPanel as the
display component) using Panel.Canvas.Copy() to copy the canvas from the
foreground bitmap. I can't believe how fast it is.

Best of all, it requires no new components or packages :)

Regards,
Brad
--
Dolphins are so intelligent that within a few weeks they can train
Americans to stand at the edge of the pool and throw them fish.

--
_______________________________________________
Lazarus mailing list
Lazarus at lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus




More information about the Lazarus mailing list