ROOT logo

From $ROOTSYS/tutorials/graphics/psview.C

// An example how to display PS, EPS, PDF files in canvas
// To load a PS file in a TCanvas, the ghostscript program needs to be install.
// - On most unix systems it is installed by default.
// - On Windows it has to be installed from http://pages.cs.wisc.edu/~ghost/
//   also the place where gswin32c.exe sits should be added in the PATH. One
//   way to do it is: 
//     1. Start the Control Panel
//     2. Double click on System
//     3, Open the "Advanced" tab
//     4. Click on the "Environment Variables" button
//     5. Find "Path" in "System varibale list", click on it.
//     6. Click on the "Edit" button.
//     7. In the "Variable value" field add the path of gswin32c 
//        (after a ";") it should be something like:
//        "C:\Program Files\gs\gs8.13\bin"
//     8. click "OK" as much as needed.
//
//Author: Valeriy Onoutchin
   
#include "TROOT.h"
#include "TCanvas.h"
#include "TImage.h"

void psview()
{
   // set to batch mode -> do not display graphics
   gROOT->SetBatch(1);

   // create a PostScript file
   gROOT->Macro("feynman.C");
   gPad->Print("feynman.eps");

   // back to graphics mode
   gROOT->SetBatch(0);

   // create an image from PS file
   TImage *ps = TImage::Open("feynman.eps");

   if (!ps) {
      printf("GhostScript (gs) program must be installed\n");
      return;
   }

   new TCanvas("psexam", "Example how to display PS file in canvas", 600, 400);
   TLatex *tex = new TLatex(0.06,0.9,"The picture below has been loaded from a PS file:");
   tex->Draw();

   TPad *eps = new TPad("eps", "eps", 0., 0., 1., 0.75);
   eps->Draw();
   eps->cd();
   ps->Draw("xxx"); 
}
 psview.C:1
 psview.C:2
 psview.C:3
 psview.C:4
 psview.C:5
 psview.C:6
 psview.C:7
 psview.C:8
 psview.C:9
 psview.C:10
 psview.C:11
 psview.C:12
 psview.C:13
 psview.C:14
 psview.C:15
 psview.C:16
 psview.C:17
 psview.C:18
 psview.C:19
 psview.C:20
 psview.C:21
 psview.C:22
 psview.C:23
 psview.C:24
 psview.C:25
 psview.C:26
 psview.C:27
 psview.C:28
 psview.C:29
 psview.C:30
 psview.C:31
 psview.C:32
 psview.C:33
 psview.C:34
 psview.C:35
 psview.C:36
 psview.C:37
 psview.C:38
 psview.C:39
 psview.C:40
 psview.C:41
 psview.C:42
 psview.C:43
 psview.C:44
 psview.C:45
 psview.C:46
 psview.C:47
 psview.C:48
 psview.C:49
 psview.C:50
 psview.C:51
 psview.C:52
 psview.C:53
thumb