Page 1 of 1

TeeCreateBitmap doesn't work if panel color is clWhite

Posted: Fri Aug 05, 2011 12:38 pm
by 16559245
If the color of the panel is clWhite, this code doesn't work:

ABitmap := Chart.TeeCreateBitmap;

The series is not visible.

This a workaround:
ABitmap := Chart.TeeCreateBitmap(TColor($FEFEFE), Chart.GetRectangle);

This seems to work since TColor($FEFEFE) <> the color of the panel.

How can this be fixed?



TeeChart v2011.03.30407
Delphi XE


Jørgen

Re: TeeCreateBitmap doesn't work if panel color is clWhite

Posted: Mon Aug 08, 2011 8:15 am
by yeray
Hello Jørgen,

I can't see any strange behaviour with the following code in v2011.03, am I missing something?
I see the same behaviour with clWhite and clRed.

Code: Select all

uses Chart, ExtCtrls;

var Chart1: TChart;
    Image1: TImage;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1:=TChart.Create(self);
  Chart1.Parent:=Form1;
  Chart1.Color:=clWhite; //clRed;

  Image1:=TImage.Create(self);
  Image1.Parent:=Form1;
  Image1.BoundsRect:=Chart1.BoundsRect;
  Image1.Top:=Chart1.Height;
end;

procedure TForm1.Button1Click(Sender: TObject);
var ABitmap: TBitmap;
begin
  ABitmap:=Chart1.TeeCreateBitmap;
  Image1.Picture.Bitmap:=ABitmap;
end;

Re: TeeCreateBitmap doesn't work if panel color is clWhite

Posted: Mon Aug 08, 2011 12:59 pm
by 16559245
Added a sample that doesn't work

It is something wrong with load from stream

(It works the second time you click)

Jørgen

Re: TeeCreateBitmap doesn't work if panel color is clWhite

Posted: Tue Aug 09, 2011 9:06 am
by yeray
Hello Jørgen,

Try forcing a Chart repaint after changing the color:

Code: Select all

  Chart1.Color := clRed; //works
  Chart1.Draw;

Re: TeeCreateBitmap doesn't work if panel color is clWhite

Posted: Tue Aug 09, 2011 9:42 am
by 16559245
It worked.

What is the reason?

Is it a bug?

Jørgen

Re: TeeCreateBitmap doesn't work if panel color is clWhite

Posted: Tue Aug 09, 2011 2:42 pm
by yeray
Hi Jørgen,

This is because TeeCreateBitmap function uses the internal Bitmap already created instead of creating a new one when UseBuffer=true (as per default). So another alternative would be setting it to false:

Code: Select all

Chart1.Canvas.UseBuffer:=false;