Problem at storing a graphic as JPEG
Posted: Thu Nov 22, 2007 11:54 am
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
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