Logo ROOT   6.14/05
Reference Guide
pad2png.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_image
3 /// \notebook
4 /// Create a canvas and save as png.
5 ///
6 /// \macro_image
7 /// \macro_code
8 ///
9 /// \author Valeriy Onuchin
10 
11 void pad2png()
12 {
13  TCanvas *c = new TCanvas;
14  TH1F *h = new TH1F("gaus", "gaus", 100, -5, 5);
15  h->FillRandom("gaus", 10000);
16  h->Draw();
17 
19 
20  TImage *img = TImage::Create();
21 
22  img->FromPad(c);
23 
24  img->WriteImage("canvas.png");
25 }
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Definition: TSystem.cxx:424
virtual void WriteImage(const char *, EImageFileTypes=TImage::kUnknown)
Definition: TImage.h:115
THist< 1, float, THistStatContent, THistStatUncertainty > TH1F
Definition: THist.hxx:285
1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:567
An abstract interface to image processing library.
Definition: TImage.h:29
virtual void FillRandom(const char *fname, Int_t ntimes=5000)
Fill histogram following distribution in function fname.
Definition: TH1.cxx:3421
R__EXTERN TSystem * gSystem
Definition: TSystem.h:540
virtual void Draw(Option_t *option="")
Draw this histogram with options.
Definition: TH1.cxx:2974
#define h(i)
Definition: RSha256.hxx:106
The Canvas class.
Definition: TCanvas.h:31
virtual void FromPad(TVirtualPad *, Int_t=0, Int_t=0, UInt_t=0, UInt_t=0)
Definition: TImage.h:122
#define c(i)
Definition: RSha256.hxx:101
static TImage * Create()
Create an image.
Definition: TImage.cxx:36