[ROOT] How to set correct size of TCanvas

From: cstrato (cstrato@aon.at)
Date: Sun Nov 10 2002 - 20:35:08 MET


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