Logo ROOT   6.16/01
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
11void 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 }
19 img->Draw("N");
20
21 TCanvas *c = (TCanvas *)gROOT->GetListOfCanvases()->FindObject("rose512jpg");
22 c->SetFixedAspectRatio();
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");
31 i1->Flip(90);
32 TImage *i2 = TImage::Open("$ROOTSYS/tutorials/image/rose512.jpg");
34 i2->Flip(180);
35 TImage *i3 = TImage::Open("$ROOTSYS/tutorials/image/rose512.jpg");
37 i3->Flip(270);
38 TImage *i4 = TImage::Open("$ROOTSYS/tutorials/image/rose512.jpg");
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}
#define d(i)
Definition: RSha256.hxx:102
#define c(i)
Definition: RSha256.hxx:101
static double p3(double t, double a, double b, double c, double d)
static double p1(double t, double a, double b)
static double p2(double t, double a, double b, double c)
const Bool_t kFALSE
Definition: RtypesCore.h:88
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define gROOT
Definition: TROOT.h:410
virtual void SetConstRatio(Bool_t constRatio=kTRUE)
Set (constRatio = kTRUE) or unset (constRadio = kFALSE) the ratio flag.
Definition: TAttImage.cxx:641
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
virtual UInt_t GetWidth() const
Definition: TImage.h:228
virtual void Mirror(Bool_t=kTRUE)
Definition: TImage.h:138
virtual void Flip(Int_t=180)
Definition: TImage.h:131
virtual UInt_t GetHeight() const
Definition: TImage.h:229
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
return c1
Definition: legend1.C:41