Problem of printing canvas to a .png file

Hi,
I try to print a canvas to a .png file something like:

    canMall->Print(fileName,"png");

which follows

    canMall->Print(fileName,"eps");

My problem is: the png file what I get is something like “screen capture picture” instead of what the canvas looks like. I am wondering why “Print” my screen but not the canvas. By the way, .eps files are all okay. I only have this problem in my long code. I cannot produce this problem in a short-code way. I attach the png file produced here for reference, which is absolutely not what I wanna get.

Thanks,
Zhiyi.
P.S. root version: 5.08/00
Mandrake linux 10.2: 2.6.11-6mdk-i686-up-4GB


Are you working in “batch” mode (ie no canvas on screen) or with an opened canvas on screen ?

I think I can re-produce this problem with a short code as follows.

{ TCanvas *can = new TCanvas("can", "can", 800, 600); TCanvas *can1 = new TCanvas("can1", "can1", 800, 600); can->cd(); TH1F *h = new TH1F("h","h", 100, -2, 2); h->FillRandom("gaus"); h->Draw(); can1->cd(); h->Draw(); can->Print("testPrint.eps","eps"); can1->Print("testPrint1.eps","eps"); can->Print("testPrint.png","png"); can1->Print("testPrint1.png","png"); }
Please look at the difference between testPrint.png and testPrint1.png. testPrint.png is not good (it has an additional gray bar on the top of the pic) and has a similar problem.

I ran you macro both in interactive mode and in batch mode on my linux box (SLC3) with The ROOT version 5.09/01, and all is fine. The two png files are correct.