Hi All,
I have a problem printing TChart objects. Here is my situation:
I have a C++ project in Borland Developer Studio which uses TCharts. These charts TeeCreateBitmap method is called to extract a bitmap object which is stored in a database for use in Crystal Reports.
The chart szies are very large (3000 x 3000), so that text and and font are in the right proportion.
This is what is expected
However, in some cases this causes an EOutOfResources occurs as these images are so large, in some cases 250mb. To try to get around this, I have tried to reduce the graph size, for example 1000 x 1000. The result is shown below:
As you can see, the proportions are all wrong in comparison to the previous chart
Is there a way to get a JPEG from the TChart? Or can I call some kind of method to get the quality I want, but not return a mammoth sized TBitmap? We are working with quite a lot of legacy code and I am sure there is good reason to make this images so large, but it is a real problem when we just want to extract a JPEG for printing.
TeeCreateBitmap Memory Problem - TChart
-
- Newbie
- Posts: 15
- Joined: Mon Nov 20, 2006 12:00 am
- Location: The Netherlands
- Contact:
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Steve,
You could try using StretchDraw as shown here. You could then use a JPEG file as shown on this other thread.
You could try using StretchDraw as shown here. You could then use a JPEG file as shown on this other thread.
This is most likely because you are using absolute positions. You should set objects's custom position relative to some object in the chart, for example: series points, axes position, legend, title, etc.As you can see, the proportions are all wrong in comparison to the previous chart
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Newbie
- Posts: 15
- Joined: Mon Nov 20, 2006 12:00 am
- Location: The Netherlands
- Contact:
-
- Newbie
- Posts: 15
- Joined: Mon Nov 20, 2006 12:00 am
- Location: The Netherlands
- Contact:
Hi Narcis,
I am not sure how this code should look using the StretchDraw method. I would like to use a TJPEGImage object, so that it can be saved to a blob stream. I don't have a direct handle to the printing process as this is done via Crystal Reports, so using code like Printer.Canvas.StretchDraw is not possible.
I should mention also that the report can be generated even if the graph has not been created in the user interface. This means the graph is created in code, but there is sharing of code between UI and printing processes. This means using Chart->ClientRect gives an error (at least I think this error is related to the fact that it is not visible).
Many thanks for the help.
I am not sure how this code should look using the StretchDraw method. I would like to use a TJPEGImage object, so that it can be saved to a blob stream. I don't have a direct handle to the printing process as this is done via Crystal Reports, so using code like Printer.Canvas.StretchDraw is not possible.
I should mention also that the report can be generated even if the graph has not been created in the user interface. This means the graph is created in code, but there is sharing of code between UI and printing processes. This means using Chart->ClientRect gives an error (at least I think this error is related to the fact that it is not visible).
Many thanks for the help.
-
- Newbie
- Posts: 15
- Joined: Mon Nov 20, 2006 12:00 am
- Location: The Netherlands
- Contact:
Hi Narcis,
I think I see what the problem is.
If I reduce the size of the graph, then the relative sizes of fonts, line widths etc are not resized. I think the best solution is to first reduce the size of the graphs overall and then also reduce the fonts, lines etc. I have tested this theory with the graph shown and it produces the sort of results I expect.
I do not understand why the graphs are as big as they are in the first place, but I am working with legacy code which was based on the standard TChart components from C++ Builder 6. Maybe there is a technical reason for it that is no longer applicable.
Thank you for all the help!
I think I see what the problem is.
If I reduce the size of the graph, then the relative sizes of fonts, line widths etc are not resized. I think the best solution is to first reduce the size of the graphs overall and then also reduce the fonts, lines etc. I have tested this theory with the graph shown and it produces the sort of results I expect.
I do not understand why the graphs are as big as they are in the first place, but I am working with legacy code which was based on the standard TChart components from C++ Builder 6. Maybe there is a technical reason for it that is no longer applicable.
Thank you for all the help!
-
- Newbie
- Posts: 15
- Joined: Mon Nov 20, 2006 12:00 am
- Location: The Netherlands
- Contact:
I forgot how we solved this in the end, but it is now working.
We store the image as a JPEG, but for a number of users this generates an exception. In this case, the image is saved in bitmap format. We never found out what it is about the small group of users' systems that causes an exception to be generated.
Thanks for all the support!
We store the image as a JPEG, but for a number of users this generates an exception. In this case, the image is saved in bitmap format. We never found out what it is about the small group of users' systems that causes an exception to be generated.
Thanks for all the support!
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Steve,
Thanks for the information. I'm glad to hear you found a solution.
Thanks for the information. I'm glad to hear you found a solution.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |