Logo ROOT   6.07/09
Reference Guide
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 }
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
Definition: TSystem.cxx:1265
virtual void ToggleEventStatus()
Toggle event statusbar.
Definition: TCanvas.cxx:2125
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:50
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:255
An abstract interface to image processing library.
Definition: TImage.h:37
virtual void SetTopMargin(Float_t topmargin)
Set Pad top margin in fraction of the pad height.
Definition: TAttPad.cxx:130
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.
Definition: TFile.cxx:3871
virtual void SetBottomMargin(Float_t bottommargin)
Set Pad bottom margin in fraction of the pad height.
Definition: TAttPad.cxx:100
R__EXTERN TSystem * gSystem
Definition: TSystem.h:549
char * Form(const char *fmt,...)
virtual void Zoom(UInt_t, UInt_t, UInt_t, UInt_t)
Definition: TImage.h:136
The Canvas class.
Definition: TCanvas.h:41
virtual void SetRightMargin(Float_t rightmargin)
Set Pad right margin in fraction of the pad width.
Definition: TAttPad.cxx:120
virtual void StartPaletteEditor()
Opens a GUI to edit the color palette.
Definition: TAttImage.cxx:779
virtual void SetLeftMargin(Float_t leftmargin)
Set Pad left margin in fraction of the pad width.
Definition: TAttPad.cxx:110