Loading [MathJax]/extensions/tex2jax.js
Logo ROOT   6.16/01
Reference Guide
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
psview.C File Reference

Detailed Description

View in nbviewer Open in SWAN 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.

#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
TString dir = gROOT->GetTutorialDir();
dir.Append("/graphics/feynman.C");
gROOT->Macro(dir);
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");
}
#define gROOT
Definition: TROOT.h:410
#define gPad
Definition: TVirtualPad.h:286
The Canvas class.
Definition: TCanvas.h:31
An abstract interface to image processing library.
Definition: TImage.h:29
static TImage * Open(const char *file, EImageFileTypes type=kUnknown)
Open a specified image file.
Definition: TImage.cxx:110
To draw Mathematical Formula.
Definition: TLatex.h:18
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:195
The most important graphics class in the ROOT system.
Definition: TPad.h:29
virtual void Draw(Option_t *option="")
Draw Pad in Current pad (re-parent pad if necessary).
Definition: TPad.cxx:1281
TVirtualPad * cd(Int_t subpadnumber=0)
Set Current pad.
Definition: TPad.cxx:594
Basic string class.
Definition: TString.h:131
TString & Append(const char *cs)
Definition: TString.h:559
static constexpr double ps
Author
Valeriy Onoutchin

Definition in file psview.C.