Steema Issues Database

Note: This database is for bugs and wishes only. For technical support help, if you are a customer please visit our online forums;
otherwise you can use StackOverflow.
Before using this bug-tracker we recommend a look at this document, Steema Bug Fixing Policy.



Bug 1959

Summary: After Zoom & JPEG Export AV can occur on re-entering Chart with Mouse
Product: VCL TeeChart Reporter: marc meumann <marc>
Component: ExportAssignee: Steema Issue Manager <issuemanager>
Status: RESOLVED NOTABUG    
Severity: major    
Priority: High    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows   
Chart Series: --- Delphi / C++ Builder RAD IDE Version:

Description marc meumann 2017-12-13 09:28:17 EST
Not easily reproducable but caused when assigned Canvas used with XOr zoom brush/pen still active (zooming out of bounds) during Chart image export (using different render Canvas) and on thereupon returning to chart with Mouse.
Comment 1 marc meumann 2017-12-13 10:46:16 EST
Solution: use TeeChart's own routines:

eg. (uses TeeJPEG, TeExport
TeeSavePanel(TJPEGExportFormat,AChart);

------
or
------

Fix applicable to application (client test) code:

Backup and restore Chart Canvas.

eg.
procedure TForm1.ExportJPEG(Sender: TObject; AChart : TChart);
var
  FName: string;
  tmpBitmap:TBitmap;
  OldCanvas : TCanvas;
begin
  OldCanvas := AChart.Canvas.ReferenceCanvas;

  with TJPEGImage.Create do begin
    tmpBitmap:=TBitmap.Create;   { <-- create a temporary TBitmap }
    try
      tmpBitmap.Width :=AChart.Width;   { <-- set the bitmap dimensions }
      tmpBitmap.Height:=AChart.Height;
      AChart.Draw(tmpBitmap.Canvas,Rect(0,0,tmpBitmap.Width,tmpBitmap.Height));
      Assign(tmpBitmap);

      SaveToFile('d:\data\output\testjpeg2.jpg'); {<-- save the JPEG to disk }
    finally
      tmpBitmap.Free;  { <-- free the temporary Bitmap }
    end;

    Free;  { <-- free the temporary JPEG object }
  end;

  AChart.Canvas.ReferenceCanvas := OldCanvas;
end;