Page 1 of 1
Accessing a bitmap with TBMPExportFormat
Posted: Fri Apr 25, 2014 8:37 pm
by 10047857
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 8890 times
Re: Accessing a bitmap with TBMPExportFormat
Posted: Mon Apr 28, 2014 10:58 am
by yeray
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;
Re: Accessing a bitmap with TBMPExportFormat
Posted: Mon Apr 28, 2014 11:18 am
by 10047857
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.
Re: Accessing a bitmap with TBMPExportFormat
Posted: Mon Apr 28, 2014 11:52 am
by yeray
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 8849 times
Find the project attached:
Re: Accessing a bitmap with TBMPExportFormat
Posted: Mon Apr 28, 2014 4:10 pm
by 10047857
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.
Re: Accessing a bitmap with TBMPExportFormat
Posted: Tue Apr 29, 2014 7:11 am
by yeray
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 8848 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.
Re: Accessing a bitmap with TBMPExportFormat
Posted: Tue Apr 29, 2014 8:59 am
by 10047857
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.