Re: [ROOT] TImage problem

From: Rene Brun (Rene.Brun@cern.ch)
Date: Fri May 09 2003 - 22:35:43 MEST


Hi Michal,

Most graphics applications require a TApplication to be created.
Look at the file in the attachement. I also fixed another problem
when building your second image.

Rene Brun

On Fri, 9 
May 2003, Michal Lijowski wrote:

> 
>    Hello,
> 
>    Below is a short program which attempts to create an image from data
>    in ASCII file (attached) and it crashes with segv. I am using root 3.05/4
>    under RH Linux 9.0.
> 
>    I appreciate your attention and any help.
> 
>    Michal
> 
>    // TestTImage.cxx
> //
> 
> #include <iostream>
> #include <fstream>
> #include <TROOT.h>
> #include <TASImage.h>
> #include <TVectorD.h>
> 
> using namespace std;
> 
> int main(int argc, char **argv)
> {
> 
> // initialize  ROOT
>     TROOT TestTImage("Test", "Test TImage");
>     string infile = "this";
>     ifstream infp(infile.c_str());
>     if (infp == NULL) {
>         cout << "  " << argv << " cannot open " << infile << endl;
>         return 1;
>     }
> // create an array
>     unsigned int NN = 40;
>     double *arr = new double[NN * NN * sizeof(double)];
>     double *lp = arr;
> // loop through the file and read numbers
> 
>     int ii = 0;
>     while (infp.good()) {
>          infp >> *lp++;
>          ii++;
>     }
>     infp.close();
> 
>     unsigned int NRows = NN * NN;
>     TVectorD *data = new TVectorD(NRows);
>     data -> SetElements(arr);
>     cout << " Print data " << endl;
>     data -> Print();
> 
>     TImage *TestImage1 = TImage::Create();
>     if (!TestImage1) {
>         cout << " Program " << argv << " cannot create an image .. " <<
> endl;
>         return 1;
>     }
>     TestImage1 -> SetImage(arr, NN, NN, 0);
> 
>     TImage *TestImage2 = TImage::Create();
>     if (!TestImage2) {
>         cout << " Program " << argv << " cannot create an image .. " <<
> endl;
>         return 1;
>     }
>     TestImage2 -> SetImage(*data, NRows, 0);
> 
>     return 0;
> }
> 
>  *** Break *** segmentation violation
>  Generating stack trace...
>  0x401a3312 in TUnixSystem::StackTrace() + 0x202 from
> /home/michal/cern/root/lib/libCore.so
>  0x401a2114 in TUnixSystem::DispatchSignals(ESignals) + 0x104 from
> /home/michal/cern/root/lib/libCore.so
>  0x401a13c5 in <unknown> from /home/michal/cern/root/lib/libCore.so
>  0x401a4be5 in <unknown> from /home/michal/cern/root/lib/libCore.so
>  0x40e017c8 in <unknown> from /lib/tls/libpthread.so.0
>  0x4152517c in TASImage::SetImage(double const*, unsigned, unsigned,
> TImagePalette*) + 0x2c from /home/michal/cern/root/lib/libASImage.so
>  0x08049644 in main + 0x444 from ./TestTImage
>  0x420156a4 in __libc_start_main + 0xe4 from /lib/tls/libc.so.6
>  0x08049171 in std::ios_base::Init::~Init [in-charge]() + 0x31 from
> ./TestTImage
> 





This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:11 MET