前面把chart画到canvas里面的例子,在图像重画时画面会出现闪烁,视觉感受很不爽。我们可以用BGRAControls里面的TBGRAVirtualScreen 控件来解决。由于pkg升级,原文里面的代码不能正常运行。修改了一下就可以了。
uses TABGRAUtils, TADrawUtils, TADrawerCanvas, BGRABitmapTypes, TADrawerBGRA;
...
procedure TForm1.Chart1BarSeries1BeforeDrawBar(ASender: TBarSeries;
ACanvas: TCanvas; const ARect: TRect; APointIndex, AStackIndex: Integer;
var ADoDefaultDrawing: Boolean);
begin
ADoDefaultDrawing:= false;
DrawPhong3DBar(ASender, ACanvas, ARect, APointIndex);
end;
procedure TForm1.BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
var
bmp: TBGRABitmap;
id: IChartDrawer;
rp: TChartRenderingParams;
begin
bmp := TBGRABitmap.Create(BGRAVirtualScreen1.Width, BGRAVirtualScreen1.Height);
Chart1.DisableRedrawing;
try
id := TBGRABitmapDrawer.Create(bmp);
id.DoGetFontOrientation := @CanvasGetFontOrientationFunc;
rp := Chart1.RenderingParams;
Chart1.Draw(id, Rect(0, 0, BGRAVirtualScreen1.Width, BGRAVirtualScreen1.Height));
Chart1.RenderingParams := rp;
Bitmap.PutImage(0,0,bmp,dmDrawWithTransparency);
finally
Chart1.EnableRedrawing;
bmp.Free;
end;
end;