root icon indicating copy to clipboard operation
root copied to clipboard

TASImage::FromPad fails in batch mode if combined with Flip

Open ferdymercury opened this issue 1 year ago • 2 comments

  • [x] Checked for duplicates

Describe the bug

TASImage::FromPad + TASImage::Flip does not work in batch mode, no matter the rotation angle.

Expected behavior

It should work also in batch mode.

To Reproduce

Run the code in batch mode below to get a black output. Comment the line Flip(0) and you'll get the correct output.

void test()
{
    TCanvas *c1 = new TCanvas("c1","c1",600,600);
    TH1F *h = new TH1F("gaus","gaus", 100, -5, 5);
    h->FillRandom("gaus", 10000);
    h->Draw();
    c1->Update();

    TCanvas *c2 = new TCanvas("c2","c1 rotated",600,600);
    TASImage *img = new TASImage();
    img->FromPad(c1);
    img->Flip(0);
    img->Mirror();
    img->Draw("x");
    c2->Print("c2.png");
}

Setup

   ------------------------------------------------------------------
  | Welcome to ROOT 6.27/01                        https://root.cern |
  | (c) 1995-2022, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for linuxx8664gcc on Apr 25 2022, 22:21:18                 |
  | From heads/master@v6-25-01-3897-gf39eb0e984                      |
  | With c++ (Ubuntu 8.4.0-1ubuntu1~18.04) 8.4.0                     |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'  |
   ------------------------------------------------------------------

Additional context

https://root-forum.cern.ch/t/bug-of-tasimage-when-use-tasimage-flip/50827/ https://root-forum.cern.ch/t/timage-rendered-in-black-in-batch-not-in-interactive-mode/16781

ferdymercury avatar Jul 19 '22 21:07 ferdymercury

As I said on the forum img2pad.C is ok. Have you tried it?

couet avatar Jul 20 '22 10:07 couet

Good point. So maybe the issue is rather in the function "FromPad" rather than in the function "Flip", because the following works:

TASImage *img = new TASImage("$ROOTSYS/tutorials/image/rose512.jpg");
img->Flip(0);

whereas the following only works in interactive mode:

TASImage *img = new TASImage();
img->FromPad(c1);
img->Flip(0);

ferdymercury avatar Jul 20 '22 11:07 ferdymercury

TASImage is some external code. It is kind of frozen these days. This issue will be hard to fix. Is it a blocker for you?

couet avatar Mar 08 '23 17:03 couet

Hi, thanks, I think this question should be asked to the original user (quzn) that reported the problem: https://root-forum.cern.ch/t/bug-of-tasimage-when-use-tasimage-flip/50827

ferdymercury avatar Mar 09 '23 07:03 ferdymercury

Thanks, I left a comment in the forum post.

couet avatar Mar 09 '23 07:03 couet