TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
-
Metman
- Advanced
- Posts: 113
- Joined: Fri Dec 21, 2007 12:00 am
Post
by Metman » Fri Apr 25, 2014 8:37 pm
Hi
I am trying to capture a bitmap of a chart. I don't want to save it, I just need a bitmap to use in a image component, where I am adding a number of graphs in a grid.
I use the following code but the bitmap ends up spoiled with a lot of vertical lines. If I save the bitmap it saves correctly - am I missing something here of is it just not possible to grab a bitmap like this?? I thought it was the pixelformat property but none of them make a difference.
Code: Select all
tmp:=TBMPExportFormat.Create;
try
tmp.Panel:=Chart;
tmp.Bitmap.PixelFormat:=pf24bit;
finally
tmp.Free;
end;
Bruce.
- Capture3.png (117.01 KiB) Viewed 8892 times
-
Yeray
- Site Admin
- Posts: 9612
- Joined: Tue Dec 05, 2006 12:00 am
- Location: Girona, Catalonia
-
Contact:
Post
by Yeray » Mon Apr 28, 2014 10:58 am
Hello Bruce,
Do you know a way we can reproduce the problem here?
I've tried to add a TChart and a TImage to a form and the following code, but the image I see in the TImage looks fine:
Code: Select all
uses Series, TeeBmpOptions;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.View3D:=false;
Chart1.Legend.Visible:=false;
Chart1.AddSeries(TAreaSeries).FillSampleValues;
end;
procedure TForm1.Button1Click(Sender: TObject);
var tmp: TBMPExportFormat;
tmpOp: TBMPOptions;
begin
tmp:=TBMPExportFormat.Create;
tmpOp:=TBMPOptions.Create(Self);
try
tmp.Panel:=Chart1;
tmp.Bitmap(tmpOp).PixelFormat:=pf24bit;
Image1.Picture.Graphic:=tmp.Bitmap(tmpOp);
finally
tmp.Free;
end;
end;
-
Metman
- Advanced
- Posts: 113
- Joined: Fri Dec 21, 2007 12:00 am
Post
by Metman » Mon Apr 28, 2014 11:18 am
Yeray
Thanks for your prompt reply.
I tried your example (I never created a TBMPOptions in my code) but was unable to add
to
because it
won't allow any parameters in the version of TeeChart (8) which I'm using. So I still can't access the bitmap from the TBMPExportFormat object with a load of vertical lines.
I am sure its all to do with the pixel format but as I said in my original post I have tried them all.
Bruce.
-
Yeray
- Site Admin
- Posts: 9612
- Joined: Tue Dec 05, 2006 12:00 am
- Location: Girona, Catalonia
-
Contact:
Post
by Yeray » Mon Apr 28, 2014 11:52 am
Hi Bruce,
Metman wrote:I tried your example (I never created a TBMPOptions in my code) but was unable to add
to
because it
won't allow any parameters in the version of TeeChart (8) which I'm using. So I still can't access the bitmap from the TBMPExportFormat object with a load of vertical lines.
I am sure its all to do with the pixel format but as I said in my original post I have tried them all.
I was with the latest version.
Now I've tried with TeeChart v8 and removing the TBMPOptions I get this in a new simple project with just a TImage and a button:
- 2014-04-28_1350.png (18.93 KiB) Viewed 8851 times
Find the project attached:
-
Metman
- Advanced
- Posts: 113
- Joined: Fri Dec 21, 2007 12:00 am
Post
by Metman » Mon Apr 28, 2014 4:10 pm
Yeray
OK, you win, that works fine after I remove the 'TeeGDIPlus' in the uses clause. It must be something I'm doing. I'll create a simple demo of what I'm doing and see if I can fix it.
Bruce.
-
Yeray
- Site Admin
- Posts: 9612
- Joined: Tue Dec 05, 2006 12:00 am
- Location: Girona, Catalonia
-
Contact:
Post
by Yeray » Tue Apr 29, 2014 7:11 am
Hi Bruce,
Adding this to the FormCreate to activate GDIPlus:
Code: Select all
Chart1.Canvas:=TGDIPlusCanvas.Create;
It still gives me a good bitmap with TeeChart v8:
- 2014-04-29_0909.png (17.45 KiB) Viewed 8850 times
Maybe you are doing something else that is causing the bitmap not to be correctly exported, so yes, it would be helpful if you could arrange that simple example we can run as-is to reproduce the problem here.
-
Metman
- Advanced
- Posts: 113
- Joined: Fri Dec 21, 2007 12:00 am
Post
by Metman » Tue Apr 29, 2014 8:59 am
Yeray
I'll try and do that demo, but you know how it is, I'm not a crack programmer and when I get a problem I can't fix, I look for help but if that doesn't work I move on and work round the problem as quickly as possible. The bitmap looked good when I saved it using the export feature in TeeChart but wouldn't copy across so you may be right the problem is not yours.
What I was trying to do was copy a bitmap of a chart as an object into a TImageENVect component (from Xequte). It worked with other bitmaps that I had extracted from other components including TGlobe and TAdvStringGrid (TMS).
Bruce.