Logo ROOT  
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
11void 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}
char * Form(const char *fmt,...)
R__EXTERN TSystem * gSystem
Definition: TSystem.h:560
virtual void StartPaletteEditor()
Opens a GUI to edit the color palette.
Definition: TAttImage.cxx:780
virtual void SetBottomMargin(Float_t bottommargin)
Set Pad bottom margin in fraction of the pad height.
Definition: TAttPad.cxx:100
virtual void SetLeftMargin(Float_t leftmargin)
Set Pad left margin in fraction of the pad width.
Definition: TAttPad.cxx:110
virtual void SetRightMargin(Float_t rightmargin)
Set Pad right margin in fraction of the pad width.
Definition: TAttPad.cxx:120
virtual void SetTopMargin(Float_t topmargin)
Set Pad top margin in fraction of the pad height.
Definition: TAttPad.cxx:130
The Canvas class.
Definition: TCanvas.h:31
virtual void ToggleEventStatus()
Toggle event statusbar.
Definition: TCanvas.cxx:2281
TObject * Get(const char *namecycle) override
Return pointer to object identified by namecycle.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition: TFile.h:48
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
Definition: TFile.cxx:3923
An abstract interface to image processing library.
Definition: TImage.h:29
virtual void Zoom(UInt_t, UInt_t, UInt_t, UInt_t)
Definition: TImage.h:128
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:195
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:1287