aperez
January 16, 2018, 9:02am
1
Dear rooters,
I am trying to draw a logo in my plots using the class TASImage. For this I just do the following,
TPad logo_pad = new TPad(“logo_pad”,“Logo pad”,lowX,lowY,highX ,highY);
logo_pad->Draw();
logo_pad->cd();
TASImage logo = new TASImage(“logo_image_file.png”);
logo->Draw(“xxx”);
where the pad is drawn in a TCanvas object.
The logo effectively gets drawn, but the resolution is quite poor. Is there any way to improve the quality of the logo image?.
Many thanks,
Alejandro
couet
January 16, 2018, 9:06am
2
what is the size of the image logo_image_file.png ?
aperez
January 16, 2018, 9:11am
3
What do you mean about the size?
aperez
January 16, 2018, 9:14am
4
If by the size you mean the file size, it is 385K.
I also tried to do
logo->SetImageQuality(TAttImage::kImgBest);
and the result is the same.
aperez
January 16, 2018, 9:21am
5
I just discovered that the problem with the low resolution of the logo is at the moment when I save the plots in eps format. When I just plot the canvas the logo quality is good.
Any ideas?
aperez
January 16, 2018, 9:22am
6
Something else, I also traied with a logo image in eps format and the resultsis the same after saving the plots in eps format.
couet
January 16, 2018, 12:11pm
7
size in pixel … along x and y axis
aperez
January 16, 2018, 5:26pm
8
I don’t know. Do you know how to extract this information from a png or eps file?
aperez
January 16, 2018, 8:59pm
10
Hello,
I ran the indentify command on both png and eps versions of the image. This is what I got,
identify logo.png
logo.png PNG 756x807 756x807+0+0 8-bit DirectClass 394KB 0.000u 0:00.000
identify logo.eps
logo.eps PS 545x576 545x576+0+0 16-bit DirectClass 194KB 0.000u 0:00.00
Does it is helpful? Let me know if you need more info.
Thanks
couet
January 17, 2018, 8:45am
11
aperez:
756x807
That seems quite large and the definition should be good enough.
Can you post the png image and the macro you used to display it ?
aperez
January 17, 2018, 10:24am
12
I don’t use a simple macro. Its is actually a package.
aperez
January 17, 2018, 10:30am
14
What I essentially do is,
TCanvas* c1 = new TCanvas(“c1”,“c1”);
c1->SetFillColor(10);
c1->SetFrameFillColor(10);
c1->SetTickx(1);
c1->SetTicky(1);
c1->SetLeftMargin(0.15);
c1->SetBottomMargin(0.15);
c1->Print(“outputfile.eps[”);
c1->Clear();
//plotting some histos and graphs.
c1->cd();
TPad logo_pad = new TPad(“logo_pad”,“Logo pad”,lowX,lowY,highX,highY);
logo_pad->Draw();
logo_pad->cd();
TASImage logo = new TASImage(logo_image);
logo->SetImageQuality(TAttImage::kImgBest);
logo->Draw(“xxx”);
c1->Print(“outputfile.eps”);
c1->Print(“outputfile.eps]”);
In this way I produce a multi-page eps file.
couet
January 17, 2018, 10:36am
15
{
TCanvas *c = new TCanvas();
c->Draw();
TPad *logo_pad = new TPad("logo_pad","Logo pad",0.1,0.7,0.3 ,1.);
logo_pad->Draw();
logo_pad->cd();
TASImage *logo = new TASImage("logo.png");
logo->Draw("xxx");
}
give me this:
which is not to band seems to me.
aperez
January 17, 2018, 10:55am
16
The logo looks good in the canva display. The problem is when you save it in eps format. This is what I get
Look at the logo in the middle of the plots. The definition is not good.
I also saved the canvas in a root format and the logo looks good.
aperez
January 17, 2018, 10:56am
17
Sorry, the logo when displaying the .root format canvas looks ugly as well.
aperez
January 17, 2018, 11:16am
18
I did this
{
TH1F *h1 = new TH1F(“h1”,“h1”,100,-5.0,5.0);
h1->FillRandom(“gaus”,10000);
TH1F *h2 = new TH1F(“h2”,“h2”,100,-5.0,5.0);
h2->FillRandom(“gaus”,100000);
TString EPSName = TString(“outfile”) + TString(".eps");
TString EPSNameO = EPSName + TString("[");
TString EPSNameC = EPSName + TString("]");
TCanvas* c1 = new TCanvas(“c1”,“c1”);
c1->SetFillColor(10);
c1->SetFrameFillColor(10);
c1->SetTickx(1);
c1->SetTicky(1);
c1->SetLeftMargin(0.15);
c1->SetBottomMargin(0.15);
//c1->SetRightMargin(0.15);
c1->Print(EPSNameO.Data());
c1->Clear();
c1->Divide(2,2);
c1->cd(1);
h1->Draw();
c1->cd(4);
h2->Draw();
c1->cd();
TPad *logo_pad = new TPad(“logo_pad”,“Logo pad”,0.5 - 0.1,0.5 - 0.1,0.5 + 0.1,0.5 + 0.1);
logo_pad->Draw();
logo_pad->cd();
TASImage *logo = new TASImage(“Guariguanchi_logo.png”);
logo->Draw(“xxx”);
c1->Print(EPSName.Data());
c1->Print(EPSNameC.Data());
}
The results that I get is
As you can see the logo is not as high definition as the original image.
couet
January 17, 2018, 12:30pm
20
Yes when you save to eps a reduce version of the logo you lose the original high definition of the png logo. The new size in eps in may be 100x100 …
aperez
January 17, 2018, 1:25pm
21
Is there any way to preserve the original resolution?