Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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");
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");
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 }