22 UInt_t color2rgb(TColor *col)
26 return ((UInt_t(col->GetRed()*255) << 16) +
27 (UInt_t(col->GetGreen()*255) << 8) +
28 UInt_t(col->GetBlue()*255));
35 Bool_t batch = gROOT->IsBatch();
38 gROOT->SetBatch(kTRUE);
41 gROOT->Macro(
"$ROOTSYS/tutorials/graphs/graph.C");
44 TImageDump dmp(
"dummy.png");
45 TImage *fore = dmp.GetImage();
48 gPad->SetCanvasSize(400, 300);
52 TImage *back = TImage::Open(
"$ROOTSYS/tutorials/image/rose512.jpg");
55 TColor *bk1 = gROOT->GetColor(gPad->GetFillColor());
56 TColor *bk2 = gROOT->GetColor(gPad->GetFrame()->GetFillColor());
57 UInt_t rgb1 = color2rgb(bk1);
58 UInt_t rgb2 = color2rgb(bk2);
61 UInt_t *argb = fore->GetArgbArray();
62 UInt_t w = fore->GetWidth();
63 UInt_t h = fore->GetHeight();
67 for (UInt_t i = 0; i < h; i++) {
68 for (UInt_t j = 0; j < w; j++) {
72 UInt_t col = argb[idx] & 0xffffff;
78 if ((col == rgb1) || (col == rgb2)) {
81 argb[idx] = 0xff000000 + col;
87 back->Merge(fore,
"alphablend", 20, 20);
90 back->WriteImage(
"trans_graph.png");
91 printf(
"*************** File trans_graph.png created ***************\n");
96 if (!batch) gROOT->SetBatch(kFALSE);