Page 1 of 1

Problem at storing a graphic as JPEG

Posted: Thu Nov 22, 2007 11:54 am
by 8438229
Hello,

I need to store as JPEG a graphic which includes a Tchart and Labels (over the Tchart). I use Borland C++ Builder 6.0 and Teechart. The method that I use is the following:

//--------------------------------------------------------------------------------------------
Graphics::TBitmap *TmpFormImage = NULL;
TJPEGImage *FormImage = NULL;

//Generate the diagram
FormESAdiagram = new TFormESAdiagram(Application,dbg,mode); // Form creation

//Store diagram with JPG format in the corresponding directory
try
{
TmpFormImage = FormESAdiagram->GetFormImage();
FormImage = new TJPEGImage();
FormImage->Assign(TmpFormImage);
FormImage->SaveToFile(filename);

}
catch(Exception &E)
{
sprintf(sentence,"%s could not be created",filename);
Serv->PrintError(WARNING,sentence, __FILE__,__LINE__);
}
if (FormImage) delete FormImage;
if (TmpFormImage) delete TmpFormImage;

Formdiagram->Close();
delete Formdiagram;

//--------------------------------------------------------------------------------------------

After several executions I realise that this function “SaveToFile” sometimes does not store correctly the graphic. What could I do to make sure that the graphic is always saved correctly?

Thanks in advance,

Elisabet

Posted: Thu Nov 22, 2007 12:01 pm
by narcis
Hello Elisabet,

Why don't you try using TAnnotationTool instead of labels over the chart and then try TeeChart's exporting features? You'll find more information on exporting and chart tools in the features demo. You may also be interested in reading Tutorial 12 - Exporting and Importing Charts. You'll find the tutorials and demo at TeeChart's program group.

Hope this helps!

Posted: Thu Nov 22, 2007 5:42 pm
by 8438229
Hello again,

Thank you so much for your support, that method works much better!! Just one question more. I need to include a Timage over the Tchart, but I don’t want to include it in the Series, I want it to be down the legend. I have tried to include a Timage using the Tchart Tools option, but this image is included inside the TcolorGridSeries and not over the Form. On the other hand, if I include a Timage that does not belong to the Tchart the function “TeeSaveToJPEGFile” does not catch this image. What could I do?


Thank you for your help,

Elisabet

Posted: Thu Nov 22, 2007 6:17 pm
by narcis
Hi Elisabet,

In that case the easiest solution is using a TRectangleTool tool. You can set it to not transparent and assign an image to its Picture property. Then you can set it to a custom position below the legend, for example:

Code: Select all

  ChartTool2.Shape.Transparency:=0;
  ChartTool2.Shape.Transparent:=false;
  ChartTool2.Shape.Picture.LoadFromFile('c:\temp\GridOverlayIssue.bmp');
  Chart1.Draw;
  tmpW:=ChartTool2.Width;
  tmpH:=ChartTool2.Height;
  ChartTool2.Shape.CustomPosition:=true;
  ChartTool2.Shape.Left := Chart1.Legend.Left;
  ChartTool2.Shape.Top := Chart1.Legend.ShapeBounds.Bottom;
  ChartTool2.Width:=tmpW;
  ChartTool2.Height:=tmpH;
Hope this helps!

Posted: Fri Nov 23, 2007 8:29 am
by 8438229
Thank you so much for your answer, that seems a good solution. But I'm afraid that TRectangleTool is not included in realese 6 because I do not see it in my TChart Tools. In which Teechart release that tool is included?
Anyway, thank you again for your fast and good support.

Elisabet

Posted: Fri Nov 23, 2007 9:04 am
by narcis
Hi Elisabet,

Rectangle tool was implemented in v7. However, current version is number 8.

You can upgrade your v6 license to v8 here.

Without using Rectangle tool you can also do something like what's discussed here.

I've also sent you an example project doing what you request.

Posted: Fri Nov 23, 2007 9:42 am
by 8438229
We are thinkg of updating the Teechart version. Teechart version 8 is compatible with Borland C++ Builder v6??

You said in your last response that you have sent me an example project doing what I requested. How can I see that exapmle project? Where have you sent me that project?

Thank your. Best regards,

Elisabet

Posted: Fri Nov 23, 2007 10:12 am
by narcis
Hi Elisabet,
We are thinkg of updating the Teechart version. Teechart version 8 is compatible with Borland C++ Builder v6??
Yes, v8 supports BCB 6.
You said in your last response that you have sent me an example project doing what I requested. How can I see that exapmle project? Where have you sent me that project?
I sent the example project at your forums profile e-mail address. You can change it at any moment and I can resend you the e-mail. I can also post the project at news://www.steema.net/steema.public.attachments newsgroup or at our website.