Logo ROOT   6.10/09
Reference Guide
img2pad.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_image
3 /// \notebook
4 /// Display image in canvas and pad.
5 ///
6 /// \macro_image
7 /// \macro_code
8 ///
9 /// \author Valeriy Onuchin
10 
11 void img2pad()
12 {
13  TImage *img = TImage::Open("$ROOTSYS/tutorials/image/rose512.jpg");
14  if (!img) {
15  printf("Could not create an image... exit\n");
16  return;
17  }
18  img->SetConstRatio(kFALSE);
19  img->Draw("N");
20 
21  TCanvas *c = (TCanvas *)gROOT->GetListOfCanvases()->FindObject("rose512jpg");
23 
24  TCanvas *c1 = new TCanvas("roses", "roses", 800, 800);
25  img->Draw("T100,100,#ffff00");
26  /*img->Draw("T100,100,#556655");*/
27  /*img->Draw("T100,100");*/
28 
29  TImage *i1 = TImage::Open("$ROOTSYS/tutorials/image/rose512.jpg");
30  i1->SetConstRatio(kFALSE);
31  i1->Flip(90);
32  TImage *i2 = TImage::Open("$ROOTSYS/tutorials/image/rose512.jpg");
33  i2->SetConstRatio(kFALSE);
34  i2->Flip(180);
35  TImage *i3 = TImage::Open("$ROOTSYS/tutorials/image/rose512.jpg");
36  i3->SetConstRatio(kFALSE);
37  i3->Flip(270);
38  TImage *i4 = TImage::Open("$ROOTSYS/tutorials/image/rose512.jpg");
39  i4->SetConstRatio(kFALSE);
40  i4->Mirror(kTRUE);
41 
42  float d = 0.40;
43  TPad *p1 = new TPad("i1", "i1", 0.05, 0.55, 0.05+d*i1->GetWidth()/i1->GetHeight(), 0.95);
44  TPad *p2 = new TPad("i2", "i2", 0.55, 0.55, 0.95, 0.55+d*i2->GetHeight()/i2->GetWidth());
45  TPad *p3 = new TPad("i3", "i3", 0.55, 0.05, 0.55+d*i3->GetWidth()/i3->GetHeight(), 0.45);
46  TPad *p4 = new TPad("i4", "i4", 0.05, 0.05, 0.45, 0.05+d*i4->GetHeight()/i4->GetWidth());
47 
48  p1->Draw();
49  p1->cd();
50  i1->Draw();
51  c1->cd();
52 
53  p2->Draw();
54  p2->cd();
55  i2->Draw();
56  c1->cd();
57 
58  p3->Draw();
59  p3->cd();
60  i3->Draw();
61  c1->cd();
62 
63  p4->Draw();
64  p4->cd();
65  i4->Draw();
66  c1->cd();
67 }
static double p3(double t, double a, double b, double c, double d)
virtual UInt_t GetHeight() const
Definition: TImage.h:229
virtual void Draw(Option_t *option="")=0
Default Draw method for all objects.
virtual void Mirror(Bool_t=kTRUE)
Definition: TImage.h:138
return c1
Definition: legend1.C:41
virtual UInt_t GetWidth() const
Definition: TImage.h:228
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:679
#define gROOT
Definition: TROOT.h:375
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:202
An abstract interface to image processing library.
Definition: TImage.h:29
TVirtualPad * cd(Int_t subpadnumber=0)
Set Current pad.
Definition: TPad.cxx:565
virtual void SetFixedAspectRatio(Bool_t fixed=kTRUE)
Fix canvas aspect ratio to current value if fixed is true.
Definition: TCanvas.cxx:1903
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:1254
The most important graphics class in the ROOT system.
Definition: TPad.h:29
static double p1(double t, double a, double b)
const Bool_t kFALSE
Definition: RtypesCore.h:92
The Canvas class.
Definition: TCanvas.h:31
virtual void Flip(Int_t=180)
Definition: TImage.h:131
static TImage * Open(const char *file, EImageFileTypes type=kUnknown)
Open a specified image file.
Definition: TImage.cxx:110
const Bool_t kTRUE
Definition: RtypesCore.h:91