Printing canvas to png or jpg format - v5.16.00

The behavior of the Print function for TCanvas appears to have changed between version 5.14.00 and 5.16.00. The entire canvas is no longer printed to the file, only a single Pad. I’ve attached a simple macro that creates the shows the problem (at least on my machine). I’m also attaching the output files.

Is this a new behavior of a bug? How can I print the entire canvas in jpg or png?

Thanks,
Chris

{
  TCanvas can("title","title",700,500);
  can.Divide(2,1);

  TH1I *hist = new TH1I("hist","hist",100,-50,50);

  TRandom rand;

  for(int i=0;i<1000;i++)
    hist->Fill(rand.Gaus()*10);

  can.cd(1);
  hist->Draw();
  can.cd(2);
  hist->Draw();

  can->Update();
  can->Print("can.jpg");
  can->Print("can.pdf");
}

can.pdf (15.1 KB)


I cannot reproduce this problem. On which system are you running?
Did you install ROOT yourself ?

Rene

I’m on a Windows XP system using the root_v5.16.00.win32.vc80.tar file. Info from the logon info:

Compiled on 29 June 2007 for win32 with thread support.

CINT/ROOT C/C++ Interpreter version 5.16.21, June 22, 2007

Chris

After playing with the example a little bit, I’ve noticed that it is only storing the active pad. If you change the active pad to the base canvas, i.e. can->cd(0), then you will have no problem.

Chris

Sorry, changing the active canvas does not consistently solve the problem. It seemed to work once and then it returned to it’s previous behavior.

Some other things we’ve noticed:

It works for pdf and gif; but fails for png and jpg.

After the macro runs (and the can->Print(“can.jpg”) command fails), you can run the same command at the ROOT prompt and it works as expected.

This is very strange behavior; I expect it is a bug.

Thanks,
Chris

You are right, this problem is visible on windows. On linux it is fine. It is a bug.
We will investigate. I’ll let you know.

Hi,
I’m working on it. Must be fixed asap.
Thanks for reporting it.

Regards, Valeriy