[Lazarus] Fast drawing to canvas

Flávio Etrusco flavio.etrusco at gmail.com
Wed Feb 8 14:37:38 CET 2012


On Wed, Feb 8, 2012 at 7:39 AM, Sven Barth <pascaldragon at googlemail.com> wrote:
> Am 08.02.2012 01:07, schrieb dhkblaszyk at zeelandnet.nl:
>>
>> Hi,
>>
>>
>> I'm drawing a bitmap to the canvas by using LoadFromRawImage in
>> combination with a TImage. The OnPaint code below works just fine. When
>>
>> I move the scrollbar, the images are drawn to the canvas, however there
>> is still a bit of flicker.
>>
>> procedure TForm1.Image1Paint(Sender: TObject);
>> begin
>>
>> Image1.Picture.Bitmap.LoadFromRawImage(bitmaplist[ScrollBar1.Position].RawImage,
>> False);
>>
>>
>> Application.ProcessMessages;
>> end;
>>
>
> Why are you calling "Application.ProcessMessages" here?
>
> Regards,
> Sven
>

Good catch. I guess the OP has used this previously to repaint
controls/images during a long-running procedure... (and even there
it's often not the best solution)
@dhlblaszyk: when you want to force the repaint of the whole control,
call Image1.Repaint. If you want to just repaint some invalidated part
of it, call Image1.Update (not sure TGraphicControl has Update, so you
may need to use Parent.Update instead). Of course you should do this
*outside* the OnPaint. Also, is Image1.Transparent set to false?
BTW what do you mean by "The images are streamed continuously from disk"?

Regards,
Flávio




More information about the Lazarus mailing list