Dear Valeri Thank you for this tip, GetGeometry() seems to give me the size of the histogram itself. Sorrowly, it does not really solve my problems since I cannot use this information to resize the canvas correctly. It would be great if there would be an option to be able to resize TCanvas to display a histogram with the correct pixel size. Best regards Christian Valeri Fine wrote: > Hello Christian, > I think the method: > > http://root.cern.ch/root/htmldoc/TCanvasImp.html#TCanvasImp:GetWindowGeo > metry > > returns you the geometry of the entire window, including frame and > other decoration. > http://root.cern.ch/root/htmldoc/TVirtualX.html#TVirtualX:GetGeometry > > See: > http://root.cern.ch/root/htmldoc/src/TCanvas.cxx.html#TCanvas:Build > for example. > Watch there > > // Get effective window parameters (with borders and menubar) > fCanvasImp->GetWindowGeometry(fWindowTopX, fWindowTopY, > fWindowWidth, fWindowHeight); > > // Get effective canvas parameters without borders > Int_t dum1, dum2; > gVirtualX->GetGeometry(fCanvasID, dum1, dum2, fCw, fCh); > > Hope this helps, Valeri > > > > >>-----Original Message----- >>From: owner-roottalk@pcroot.cern.ch >> > [mailto:owner-roottalk@pcroot.cern.ch] > >>On Behalf Of cstrato >>Sent: Sunday, November 10, 2002 2:35 PM >>To: roottalk@pcroot.cern.ch >>Subject: [ROOT] How to set correct size of TCanvas >> >>Dear Rooters >> >>Below is a short macro where I use TH2F::SetCellContent() >>to draw an image: .x DrawImage(640,480,"COLZ") >> >>My question is: >>How can I set the size of TCanvas so that an image of size >>640 x 480 is displayed exactly with 640 x 480 screen pixels? >> >>When I create a GUI, how can I display the image in a TFrame >>with the correct pixel size? >> >>Is there a way to find out the current pixel settings of a >>monitor (e.g. 1024 x 768) from within ROOT? >> >>Thank you in advance for your help. >> >>Best regards >>Christian >>_._._._._._._._._._._._._._._._ >>C.h.i.s.t.i.a.n S.t.r.a.t.o.w.a >>V.i.e.n.n.a A.u.s.t.r.i.a >>_._._._._._._._._._._._._._._._ >> >> >>//------------------macro------------------------------------ >>void DrawImage(Int_t nrows, Int_t ncols, Option_t *opt) >>{ >> Double_t img[1000][1000]; >> for (Int_t i=0;i<nrows;i++) { >> for (Int_t j=0;j<ncols;j++) { >> img[i][j] = i + j; >> }//for_j >> }//for_i >> >> TCanvas *c1 = new TCanvas("c1","Image example",200,10,700,700); >> >> TH2F *h2; >> Double_t min = 0; >> Double_t max = TMath::Max(nrows,ncols); >> h2 = new TH2F("H2","Image test",nrows,0,nrows,ncols,0,ncols); >> h2->SetMinimum(min); >> h2->SetMaximum(max); >> for (Int_t i=0;i<nrows;i++) { >> for (Int_t j=0;j<ncols;j++) { >> h2->SetCellContent(i+1,j+1,img[i][j]); >> }//for_j >> }//for_i >> >> gStyle->SetPalette(1,0); >> gStyle->SetOptStat(0000000); >> >> h2->Draw(opt); >>}//DrawImage >> > > >
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:17 MET