Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
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/files\n", fname);
28 gal = TFile::Open(Form("http://root.cern/files/%s", fname));
29 }
30 if (!gal)
31 return;
32 TImage *img = (TImage *)gal->Get("n4254");
33 img->Draw();
34
35 // open the color editor
36 img->StartPaletteEditor();
37
38 // zoom the image
39 img->Zoom(80, 80, 250, 250);
40}
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2496
externTSystem * gSystem
Definition TSystem.h:582
virtual void StartPaletteEditor()
Opens a GUI to edit the color palette.
virtual void SetBottomMargin(Float_t bottommargin)
Set Pad bottom margin in fraction of the pad height.
Definition TAttPad.cxx:98
virtual void SetLeftMargin(Float_t leftmargin)
Set Pad left margin in fraction of the pad width.
Definition TAttPad.cxx:108
virtual void SetRightMargin(Float_t rightmargin)
Set Pad right margin in fraction of the pad width.
Definition TAttPad.cxx:118
virtual void SetTopMargin(Float_t topmargin)
Set Pad top margin in fraction of the pad height.
Definition TAttPad.cxx:128
The Canvas class.
Definition TCanvas.h:23
virtual void ToggleEventStatus()
Toggle event statusbar.
Definition TCanvas.cxx:2426
TObject * Get(const char *namecycle) override
Return pointer to object identified by namecycle.
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
Definition TFile.h:130
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:3787
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:293