ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
img2pad.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_image
3 /// Display image in canvas and pad.
4 ///
5 /// \macro_image
6 /// \macro_code
7 ///
8 /// \author Valeriy Onuchin
9 
10 void img2pad()
11 {
12  TImage *img = TImage::Open("$ROOTSYS/tutorials/image/rose512.jpg");
13  if (!img) {
14  printf("Could not create an image... exit\n");
15  return;
16  }
17  img->SetConstRatio(kFALSE);
18  img->Draw("N");
19 
20  TCanvas *c = (TCanvas *)gROOT->GetListOfCanvases()->FindObject("rose512jpg");
22 
23  TCanvas *c1 = new TCanvas("roses", "roses", 800, 800);
24  img->Draw("T100,100,yellow");
25  //img->Draw("T100,100,#556655");
26  //img->Draw("T100,100");
27 
28  TImage *i1 = TImage::Open("$ROOTSYS/tutorials/image/rose512.jpg");
29  i1->SetConstRatio(kFALSE);
30  i1->Flip(90);
31  TImage *i2 = TImage::Open("$ROOTSYS/tutorials/image/rose512.jpg");
32  i2->SetConstRatio(kFALSE);
33  i2->Flip(180);
34  TImage *i3 = TImage::Open("$ROOTSYS/tutorials/image/rose512.jpg");
35  i3->SetConstRatio(kFALSE);
36  i3->Flip(270);
37  TImage *i4 = TImage::Open("$ROOTSYS/tutorials/image/rose512.jpg");
38  i4->SetConstRatio(kFALSE);
39  i4->Mirror(kTRUE);
40 
41  float d = 0.40;
42  TPad *p1 = new TPad("i1", "i1", 0.05, 0.55, 0.05+d*i1->GetWidth()/i1->GetHeight(), 0.95);
43  TPad *p2 = new TPad("i2", "i2", 0.55, 0.55, 0.95, 0.55+d*i2->GetHeight()/i2->GetWidth());
44  TPad *p3 = new TPad("i3", "i3", 0.55, 0.05, 0.55+d*i3->GetWidth()/i3->GetHeight(), 0.45);
45  TPad *p4 = new TPad("i4", "i4", 0.05, 0.05, 0.45, 0.05+d*i4->GetHeight()/i4->GetWidth());
46 
47  p1->Draw();
48  p1->cd();
49  i1->Draw();
50  c1->cd();
51 
52  p2->Draw();
53  p2->cd();
54  i2->Draw();
55  c1->cd();
56 
57  p3->Draw();
58  p3->cd();
59  i3->Draw();
60  c1->cd();
61 
62  p4->Draw();
63  p4->cd();
64  i4->Draw();
65  c1->cd();
66 }
static double p3(double t, double a, double b, double c, double d)
virtual void Draw(Option_t *option="")=0
Default Draw method for all objects.
virtual void Mirror(Bool_t=kTRUE)
Definition: TImage.h:154
return c
TCanvas * c1
Definition: legend1.C:2
virtual void SetConstRatio(Bool_t constRatio=kTRUE)
Set (constRatio = kTRUE) or unset (constRadio = kFALSE) the ratio flag.
Definition: TAttImage.cxx:641
TVirtualPad * cd(Int_t subpadnumber=0)
Set current canvas & pad.
Definition: TCanvas.cxx:659
#define gROOT
Definition: TROOT.h:344
virtual UInt_t GetWidth() const
Definition: TImage.h:244
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:254
An abstract interface to image processing library.
Definition: TImage.h:45
TVirtualPad * cd(Int_t subpadnumber=0)
Set Current pad.
Definition: TPad.cxx:514
virtual void SetFixedAspectRatio(Bool_t fixed=kTRUE)
Fix canvas aspect ratio to current value if fixed is true.
Definition: TCanvas.cxx:1877
int d
Definition: tornado.py:11
static double p2(double t, double a, double b, double c)
virtual void Draw(Option_t *option="")
Draw Pad in Current pad (re-parent pad if necessary).
Definition: TPad.cxx:1192
virtual UInt_t GetHeight() const
Definition: TImage.h:245
The most important graphics class in the ROOT system.
Definition: TPad.h:46
static double p1(double t, double a, double b)
The Canvas class.
Definition: TCanvas.h:48
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
virtual void Flip(Int_t=180)
Definition: TImage.h:147
static TImage * Open(const char *file, EImageFileTypes type=kUnknown)
Open a specified image file.
Definition: TImage.cxx:110
const Bool_t kTRUE
Definition: Rtypes.h:91