Logo ROOT  
Reference Guide
galaxy_image.C File Reference

Detailed Description

View in nbviewer Open in SWAN Importing an image and manipulating it.

void galaxy_image()
{
TCanvas *canv = new TCanvas("image", "n4254", 40, 40, 812, 700);
canv->SetRightMargin(0.2);
canv->SetLeftMargin(0.01);
canv->SetTopMargin(0.01);
canv->SetBottomMargin(0.01);
// read the pixel data from file "galaxy.root"
// the size of the image is 401 X 401 pixels
const char *fname = "galaxy.root";
TFile *gal = 0;
if (!gSystem->AccessPathName(fname)) {
gal = TFile::Open(fname);
} else {
printf("accessing %s file from http://root.cern.ch/files\n",fname);
gal = TFile::Open(Form("http://root.cern.ch/files/%s",fname));
}
if (!gal) return;
TImage *img = (TImage*)gal->Get("n4254");
img->Draw();
// open the color editor
// zoom the image
img->Zoom(80, 80, 250, 250);
}
Author
Valeriy Onuchin

Definition in file galaxy_image.C.

TAttPad::SetTopMargin
virtual void SetTopMargin(Float_t topmargin)
Set Pad top margin in fraction of the pad height.
Definition: TAttPad.cxx:129
Form
char * Form(const char *fmt,...)
TFile::Open
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:3946
TImage
Definition: TImage.h:29
TSystem::AccessPathName
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:1294
TDirectoryFile::Get
TObject * Get(const char *namecycle) override
Return pointer to object identified by namecycle.
Definition: TDirectoryFile.cxx:909
TAttPad::SetBottomMargin
virtual void SetBottomMargin(Float_t bottommargin)
Set Pad bottom margin in fraction of the pad height.
Definition: TAttPad.cxx:99
TAttImage::StartPaletteEditor
virtual void StartPaletteEditor()
Opens a GUI to edit the color palette.
Definition: TAttImage.cxx:780
TCanvas::ToggleEventStatus
virtual void ToggleEventStatus()
Toggle event statusbar.
Definition: TCanvas.cxx:2442
TFile
Definition: TFile.h:54
gSystem
R__EXTERN TSystem * gSystem
Definition: TSystem.h:559
TAttPad::SetLeftMargin
virtual void SetLeftMargin(Float_t leftmargin)
Set Pad left margin in fraction of the pad width.
Definition: TAttPad.cxx:109
TObject::Draw
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:197
TAttPad::SetRightMargin
virtual void SetRightMargin(Float_t rightmargin)
Set Pad right margin in fraction of the pad width.
Definition: TAttPad.cxx:119
TCanvas
Definition: TCanvas.h:23
TImage::Zoom
virtual void Zoom(UInt_t, UInt_t, UInt_t, UInt_t)
Definition: TImage.h:128