TeeCreateBitmap and TeeCreateMetafile produce empty results

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
UweK
Newbie
Newbie
Posts: 7
Joined: Thu Aug 07, 2014 12:00 am

TeeCreateBitmap and TeeCreateMetafile produce empty results

Post by UweK » Tue Nov 04, 2014 3:11 pm

Hi,

I need the same data point images that are shown in a TChart from a TPointSeries (triangle, circle etc. with a particular color), to display them outside of the TChart, e.g. to show them in a TSpeedButton.Glyph, or to print them in a table header. When I wrote that part of my program some years ago, I could not find any TeeChart procedure that would directly yield these images. So I wrote the workaround shown below - but now it doesn't work anymore. If there should be any procedure like this available today, then that workaround would be obsolete, and I would be just happy to learn what that procedure is.

My workaround worked fine with Delphi 2010 (Win 7 32 bit) and several previous TeeChart versions. But now I had to update to Rad Studio Delphi XE6 (on the same PC) and the latest TeeChart Binary installer from September 2014. Now suddenly the workaround produces empty TBitmap and TMetafile results. There has been no change in the source code at all, just recompiled with the new Delphi and TeeChart.

In the workaround, I create a small temporary TChart (not even shown on the screen) with a TPointSeries in it that just contains one point in the center, no axes, legend etc. Then I capture the image of this point into a TBitmap using TeeCreateBitmap, and into a TMetafile using TeeCreateMetafile. But these now remain empty. Have there possibly been any internal modifications in the TChart component that produce this bug under these particular circumstances?.

To make it easier to understand, the code shows only a simplified version of my workaround to produce a single TBitmap and TMetafile. In my real program I produce a full set of all possible combinations from a list of colors and a list of TSeriesPointerStyle.

Thanks in advance for your help. Regards, Uwe

Code: Select all

const
  PointColor = clRed;
  PointEdgeColor = clBlack;
  PointImageSize = 14;
  PointStyle = psRectangle;
  PointBitmapBackgroundColor = clWhite;
var
  TempChart: TChart;
  TempPointSeries: TPointSeries;
  PointBitmap: TBitmap;
  PointMetafile: TMetafile;
begin
  TempChart:= TChart.Create(Self);
  TempPointSeries:= TPointSeries.Create(TempChart);
  try

    with TempChart do
    begin
      Width:= PointImageSize;
      Height:= PointImageSize;
      BevelOuter:= bvNone;
      Color:= clNone;
      BackColor:= clNone;
      MarginLeft:= 0;
      MarginRight:= 0;
      MarginTop:= 0;
      MarginBottom:= 0;
      AxisVisible:= false;
      Title.Visible:= false;
      Legend.Visible:= false;
      Frame.Visible:= false;
      View3DWalls:= false;
      RecalcWidthHeight;
      AddSeries(TempPointSeries);
    end; {with TempChart}

    with TempPointSeries.Pointer do
    begin
      Style:= PointStyle;
      Pen.Color:= PointEdgeColor;
      Brush.Color:= PointColor;
    end; {with TempPointSeries.Pointer}
    TempPointSeries.AddXY(0, 0);

    with TempChart do
    begin
      PointBitmap:= TeeCreateBitmap(PointBitmapBackgroundColor, ChartRect);
      PointMetafile:= TeeCreateMetafile(true, ChartRect);
    end; {with TempChart}
    TempPointSeries.Clear;

  finally
    TempPointSeries.Free;
    TempChart.Free;
  end; {finally}

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

Re: TeeCreateBitmap and TeeCreateMetafile produce empty results

Post by Yeray » Wed Nov 05, 2014 11:20 am

Hello,

I've pasted your code in a new simple project and added this few lines to use the bitmap generated:

Code: Select all

  with TImage.Create(Self) do
  begin
    Parent:=Self;
    Picture.Bitmap:=PointBitmap;
  end;
If I run it with Delphi 7, I can see the image without problems, but not with XE6.

We'll continue investigating this.
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

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

Re: TeeCreateBitmap and TeeCreateMetafile produce empty results

Post by Yeray » Wed Nov 05, 2014 3:29 pm

Hi,
Yeray wrote:If I run it with Delphi 7, I can see the image without problems, but not with XE6.

We'll continue investigating this.
I see ChartRect gives an empty Rectangle so Bitmap/Metafile created is empty.
Changing it for this works fine for me here:

Code: Select all

    with TempChart do
    begin
      PointBitmap:= TeeCreateBitmap(PointBitmapBackgroundColor, Rect(0, 0, TempChart.Width, TempChart.Height));
      PointMetafile:= TeeCreateMetafile(true, Rect(0, 0, TempChart.Width, TempChart.Height));
    end; {with TempChart}
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

UweK
Newbie
Newbie
Posts: 7
Joined: Thu Aug 07, 2014 12:00 am

Re: TeeCreateBitmap and TeeCreateMetafile produce empty results

Post by UweK » Wed Nov 05, 2014 4:42 pm

Thanks a lot. The problem has been solved.
In general, I think that a direct procedure to obtain these glyph images from the TChart could also be useful for other users, so I suggest to put it on the wish list.
Regards, Uwe

Post Reply