Logo ROOT   6.07/09
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:421
return c
virtual void WriteImage(const char *, EImageFileTypes=TImage::kUnknown)
Definition: TImage.h:123
THist< 1, float, THistStatContent, THistStatUncertainty > TH1F
Definition: THist.hxx:302
TH1 * h
Definition: legend2.C:5
tomato 1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:575
An abstract interface to image processing library.
Definition: TImage.h:37
virtual void FillRandom(const char *fname, Int_t ntimes=5000)
Fill histogram following distribution in function fname.
Definition: TH1.cxx:3295
R__EXTERN TSystem * gSystem
Definition: TSystem.h:549
virtual void Draw(Option_t *option="")
Draw this histogram with options.
Definition: TH1.cxx:2853
The Canvas class.
Definition: TCanvas.h:41
virtual void FromPad(TVirtualPad *, Int_t=0, Int_t=0, UInt_t=0, UInt_t=0)
Definition: TImage.h:130
static TImage * Create()
Create an image.
Definition: TImage.cxx:36