How to remove white border of transparent pad

Hello,
I have a transparent pad with an image on top of a canvas, which is showing a white border which I want to remove, see attached screenshot. However, I do not know how to do it by command line. If I right-click on the border via the GUI, then press SetLineAttributes and set the opacity to zero, it works. Any hint how could I achieve this in my script?

See a minimal working example below with silly images. Tested with ROOT master.

void test_pad()
{
	TGMainFrame* mf = new TGMainFrame(gClient->GetRoot(), 100, 100);
	mf->SetCleanup(kDeepCleanup);
	
	gStyle->SetCanvasPreferGL();//NEEDED for fast drawing.
	gStyle->SetOptStat(0);
	gStyle->SetNumberContours(255);//2D
	gStyle->SetPadTopMargin(0.);
	gStyle->SetPadRightMargin(0.);
	gStyle->SetPadBottomMargin(0.);
	gStyle->SetPadLeftMargin(0.);
	
	TRootEmbeddedCanvas* fCanvas = new TRootEmbeddedCanvas("c",mf,600,600);
		
	mf->AddFrame(fCanvas, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 2, 2, 2, 2));
	
	mf->SetWindowName("testpad");
	mf->MapSubwindows();
	mf->Resize(mf->GetDefaultSize());
	mf->MapWindow();
	
	TImage* fWater = TImage::Open("water.jpg");
	fWater->Draw("X");
	
	TPad *p = new TPad("p","p",0.2,0.2,0.8,0.8);
	p->SetFillStyle(4000);
	p->SetFrameFillStyle(4000);
	p->Draw();
	p->cd();
	TImage *img = TImage::Open("chili.png");
	img->Draw();
}








Once you have changed the opacity to 0., save the canvas as a .C file and you will see, is the created macro, what is needed.

Thanks for the idea, but this approach does not work. When I save the canvas as test.C, close ROOT, and run root -l test.C, I get again the white border.

See attached test.C
test.C (863 KB)

When I run your initial macro I am not able to display the GUI … what have you done ?

I just saved the initial macro to a file called test_pad.cpp and run it as “root -l test_pad.cpp”, see attachment. You need also to save chili.png and water.jpg in the same directory. Then I put the mouse on the white line border (this is tricky because it is thin), right-click, and then SetLineAttributes.

[code]Ubuntu 16.04

| Welcome to ROOT 6.09/01 http://root.cern.ch |
| © 1995-2016, The ROOT Team |
| Built for linuxx8664gcc |
| From heads/master@v6-09-01-415-ge249831, Nov 18 2016, 15:35:41 |

Try ‘.help’, ‘.demo’, ‘.license’, ‘.credits’, ‘.quit’/’.q’

[/code]
test_pad.cpp (884 Bytes)

You macro gives me the attached picture … no way to show the GUI like in you first Screen shot


That is very tricky. Just move very slowly the mouse from inside the (inner) pad to outside the main canvas. At some point, the mouse will show you the option to resize the pad, right click then.

I think this is a bug, that happens only when SetCanvasPreferGL is called. A white border is shown, even if you specify SetFrameLineWidth(0). Without GL it works fine.

If GL is active, I found a long and dirty workaround. If I add these lines at the end of my script, I am able to hide the white border:

	Int_t ci = TColor::GetFreeColorIndex();
	TColor *color = new TColor(ci, 0,0,0,"",0.);
	((TFrame*)p->FindObject("TFrame"))->SetLineColor(ci);