Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
galaxy_image.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_image
3 /// \notebook
4 /// Importing an image and manipulating it.
5 ///
6 /// \image html image_galaxy_image.png
7 /// \macro_code
8 ///
9 /// \author Valeriy Onuchin
10 
11 void galaxy_image()
12 {
13  TCanvas *canv = new TCanvas("image", "n4254", 40, 40, 812, 700);
14  canv->ToggleEventStatus();
15  canv->SetRightMargin(0.2);
16  canv->SetLeftMargin(0.01);
17  canv->SetTopMargin(0.01);
18  canv->SetBottomMargin(0.01);
19 
20  // read the pixel data from file "galaxy.root"
21  // the size of the image is 401 X 401 pixels
22  const char *fname = "galaxy.root";
23  TFile *gal = 0;
24  if (!gSystem->AccessPathName(fname)) {
25  gal = TFile::Open(fname);
26  } else {
27  printf("accessing %s file from http://root.cern.ch/files\n",fname);
28  gal = TFile::Open(Form("http://root.cern.ch/files/%s",fname));
29  }
30  if (!gal) return;
31  TImage *img = (TImage*)gal->Get("n4254");
32  img->Draw();
33 
34  // open the color editor
35  img->StartPaletteEditor();
36 
37  // zoom the image
38  img->Zoom(80, 80, 250, 250);
39 }