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 - After Zoom & JPEG Export AV can occur on re-entering Chart with Mouse
Summary: After Zoom & JPEG Export AV can occur on re-entering Chart with Mouse
Status: RESOLVED NOTABUG
Alias: None
Product: VCL TeeChart
Classification: Unclassified
Component: Export (show other bugs)
Version: unspecified
Hardware: PC Windows
: High major
Target Milestone: ---
Assignee: Steema Issue Manager
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-12-13 09:28 EST by marc meumann
Modified: 2017-12-13 10:46 EST (History)
0 users

See Also:
Chart Series: ---
Delphi / C++ Builder RAD IDE Version:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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;