StrechDraw is super slow

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
lnebel
Newbie
Newbie
Posts: 2
Joined: Fri Sep 29, 2017 12:00 am

StrechDraw is super slow

Post by lnebel » Fri Jan 26, 2018 10:05 am

Hi Steema

I need to draw an image on the canvas (GDI+) with transparency and a transparent color. That works with StrechDraw, however, it is SUPER slow!

My code is something like this:

Code: Select all

var
  Blend : TTeeBlend; 
  Bitmap : TBitmap;
begin
  ...
  Blend := Chart.Canvas.BeginBlending(Chart.ChartRect, 50); 
  Chart.Canvas.StretchDraw(Chart.ChartRect, Bitmap);
  Chart.Canvas.EndBlending(Blend);
end;
Within the source code for TGDIPlusCanvas.StretchDraw, I see the following comment:

// Very slow operation.
// Transparent "ABitmap" should be converted before arriving here.

Yes, so true, but how should I do that? It seems that StretchDraw will convert the image regardless of bitmap class?

\Lars

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: StrechDraw is super slow

Post by Yeray » Fri Jan 26, 2018 12:49 pm

Hello,

Try converting the Bitmap with TranspBitmap function:

Code: Select all

type TTeeCanvas3DAccess=class(TTeeCanvas3D);
//...
  tmpB:=TTeeCanvas3DAccess(Chart.Canvas).TranspBitmap(Bitmap,Chart.ChartRect);
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

lnebel
Newbie
Newbie
Posts: 2
Joined: Fri Sep 29, 2017 12:00 am

Re: StrechDraw is super slow

Post by lnebel » Fri Jan 26, 2018 1:25 pm

Thanks a lot, works perfectly!

You should add that conversion to the StrechDraw method

\Lars

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: StrechDraw is super slow

Post by Yeray » Fri Jan 26, 2018 2:34 pm

Hello,
lnebel wrote:You should add that conversion to the StrechDraw method
Actually, I took the idea from there:

Code: Select all

procedure TGDIPlusCanvas.StretchDraw(const ARect:TRect; const AGraphic:TGraphic);
//...
  if AGraphic is TBitmap then
     DoDraw(TBitmap(AGraphic))
  else
  if AGraphic is TMetafile then
     DrawMetafile
  else
  if AGraphic is TIcon then
     DrawIcon
  else
  begin
    tmpB:=TranspBitmap(AGraphic,ARect);
    DoDraw(tmpB);
    tmpB.Free;
  end;
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply