{ "cells": [ { "cell_type": "markdown", "id": "5d159064", "metadata": {}, "source": [ "# img2pad\n", "Display image in canvas and pad.\n", "\n", "\n", "\n", "\n", "**Author:** Valeriy Onuchin \n", "This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Tuesday, May 19, 2026 at 08:38 PM." ] }, { "cell_type": "code", "execution_count": 1, "id": "d1241ba3", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:38:41.770969Z", "iopub.status.busy": "2026-05-19T20:38:41.770856Z", "iopub.status.idle": "2026-05-19T20:38:42.301595Z", "shell.execute_reply": "2026-05-19T20:38:42.300919Z" } }, "outputs": [], "source": [ "TString fname = gROOT->GetTutorialDir();\n", "fname.Append(\"/visualisation/image/rose512.jpg\");\n", "TImage *img = TImage::Open(fname);\n", "\n", "if (!img) {\n", " printf(\"Could not create an image... exit\\n\");\n", " return;\n", "}\n", "\n", "img->SetConstRatio(kFALSE);\n", "img->Draw(\"N\");\n", "\n", "TCanvas *c = (TCanvas *)gROOT->GetListOfCanvases()->FindObject(\"rose512jpg\");\n", "c->SetFixedAspectRatio();\n", "\n", "TCanvas *c1 = new TCanvas(\"roses\", \"roses\", 800, 800);\n", "img->Draw(\"T100,100,#ffff00\");\n", "/*img->Draw(\"T100,100,#556655\");*/\n", "/*img->Draw(\"T100,100\");*/\n", "\n", "TImage *i1 = TImage::Open(fname);\n", "i1->SetConstRatio(kFALSE);\n", "i1->Flip(90);\n", "TImage *i2 = TImage::Open(fname);\n", "i2->SetConstRatio(kFALSE);\n", "i2->Flip(180);\n", "TImage *i3 = TImage::Open(fname);\n", "i3->SetConstRatio(kFALSE);\n", "i3->Flip(270);\n", "TImage *i4 = TImage::Open(fname);\n", "i4->SetConstRatio(kFALSE);\n", "i4->Mirror(kTRUE);\n", "\n", "float d = 0.40;\n", "TPad *p1 = new TPad(\"i1\", \"i1\", 0.05, 0.55, 0.05 + d * i1->GetWidth() / i1->GetHeight(), 0.95);\n", "TPad *p2 = new TPad(\"i2\", \"i2\", 0.55, 0.55, 0.95, 0.55 + d * i2->GetHeight() / i2->GetWidth());\n", "TPad *p3 = new TPad(\"i3\", \"i3\", 0.55, 0.05, 0.55 + d * i3->GetWidth() / i3->GetHeight(), 0.45);\n", "TPad *p4 = new TPad(\"i4\", \"i4\", 0.05, 0.05, 0.45, 0.05 + d * i4->GetHeight() / i4->GetWidth());\n", "\n", "p1->Draw();\n", "p1->cd();\n", "i1->Draw();\n", "c1->cd();\n", "\n", "p2->Draw();\n", "p2->cd();\n", "i2->Draw();\n", "c1->cd();\n", "\n", "p3->Draw();\n", "p3->cd();\n", "i3->Draw();\n", "c1->cd();\n", "\n", "p4->Draw();\n", "p4->cd();\n", "i4->Draw();\n", "c1->cd();" ] }, { "cell_type": "markdown", "id": "3e3fbf3c", "metadata": {}, "source": [ "Draw all canvases " ] }, { "cell_type": "code", "execution_count": 2, "id": "74fa3a78", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:38:42.303649Z", "iopub.status.busy": "2026-05-19T20:38:42.303507Z", "iopub.status.idle": "2026-05-19T20:38:42.668295Z", "shell.execute_reply": "2026-05-19T20:38:42.667623Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "