Redirecting graphic output to file?

Hi fellow Rooters,

I was wondering if it is possible to redirect graphic window output to a Postscript file. I know that by creating a TCanvas and using Print() method I can put a snapshot of the canvas into a Postscript file… but can it be done for a TBrowser for example?

And suppose I wish to make multiple captures of the same TCanvas into a Postscript file. Is there a way to instruct ROOT to print the snapshots into a single Postscript file (as in having multiple pages in a single file), instead of overwriting the same one or creating different ones?

Thanks.

You will find all the information about PS usage in ROOT here:
root.cern.ch/root/HowtoPS.html

Thanks couet, this is just what I was looking for in the second part.

As for the first question: do you (or anyone else) know how to “automatically” redirect graphical output to a file, without having to issue Print()s for TCanvases? I.e., suppose I wish to make a screen capture of each window that is opened (e.g. a TBrowser) to a file that I specify. I.e., I tell ROOT that instead of having the windows sent to screen, to send them to a specified file. Can this be done?

Thanks in advance.

For a screen capture of a TCanvas (which, I guess, means that you want to see the GUI around the graphics) you should use an external tool like “xv” (on linux) or one of the many sceen capture tools on Windows.

Hi again,

So I suppose ROOT has no “automatic” redirection of graphic output? I’m trying to find a way to make screen captures as they appear, independently of the type of GUI that shows up at the time (be it a TBrowser or a TTree::StartViewer() or any other for that matter).

The reason I’m asking this is that I’m trying to find a way to have ROOT console (and GUI) output automatically exported to Web-readable files (ASCII text and GIF/PNG/JPG images, respectively) based on a input script processed by ROOT.

  1. if you want to capture (as gif for example) the graphical part of a canvas you can do it within ROOT.

  2. if you want to capture (as gif for example) the canvas with the window decoration coming from the window manager and the GUI around the graphics you need an external program.

OK, that’s what I need to know, I just wasn’t sure (I didn’t know about the many-plots-in-one-Postscript though). Thanks for your help.

Check this page
root.bnl.gov/QtRoot/QtRoot.html#gifbatch
also

Hi,
you can use the following code to “save” context of the window

TGWindow *wid; // window to save
Int_t xy;  
UInt_t w, h;
GCValues_t gval;
GContext_t gc = gVirtualX->CreateGC(gVirtualX->GetDefaultRootWindow(), &gval)
gVirtualX->GetWindowSize(wid->GetId(), xy, xy, w, h); // get size
Pixmap_t p = gVirtualX->CreatePixmap(gVirtualX->GetDefaultRootWindow(), w, h)
gVirtualX->CopyArea(wid->GetId(), p, gc, 0, 0, w, h, 0, 0);
TImage *i = TImage::Create();
i->SetImage(p);
i->WriteImage("qq.png");

[quote=“Valeriy Onuchin”]Hi,
you can use the following code to “save” context of the window

TGWindow *wid; // window to save Int_t xy; UInt_t w, h; GCValues_t gval; GContext_t gc = gVirtualX->CreateGC(gVirtualX->GetDefaultRootWindow(), &gval) gVirtualX->GetWindowSize(wid->GetId(), xy, xy, w, h); // get size Pixmap_t p = gVirtualX->CreatePixmap(gVirtualX->GetDefaultRootWindow(), w, h) gVirtualX->CopyArea(wid->GetId(), p, gc, 0, 0, w, h, 0, 0); TImage *i = TImage::Create(); i->SetImage(p); i->WriteImage("qq.png"); [/quote]

It is very confusing.

This code must be hiden behind the TVirtualX::WritePixmap user interface implementation.
root.cern.ch/root/htmldoc/TVirtu … ritePixmap

Just read what ROOT had promised. It promised to do that without any extra user effort.

Hi,
I just intorduced a method which does this work (now in CVS)
TImage::FromWindow creates an image from content
of some window/pixmap.

Use TImage::WriteImage to save the produced image in
your preferable format.

Regards. Valeriy

Valeriy,

This cannot be the final user interface.
To be discussed. Please no more iteration on this topic until
we agree on the interface.

Rene