当前位置: 首页>>代码示例>>C++>>正文


C++ TImage::SetConstRatio方法代码示例

本文整理汇总了C++中TImage::SetConstRatio方法的典型用法代码示例。如果您正苦于以下问题:C++ TImage::SetConstRatio方法的具体用法?C++ TImage::SetConstRatio怎么用?C++ TImage::SetConstRatio使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TImage的用法示例。


在下文中一共展示了TImage::SetConstRatio方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: img2pad

void img2pad()
{
   // Display image in canvas and pad.
   //Author: valeriy Onuchin
   
   TImage *img = TImage::Open("rose512.jpg");
   if (!img) {
      printf("Could not create an image... exit\n");
      return;
   }
   img->SetConstRatio(kFALSE);
   img->Draw("N");

   TCanvas *c = gROOT->GetListOfCanvases()->FindObject("rose512jpg");
   c->SetFixedAspectRatio();

   TCanvas *c = new TCanvas("roses", "roses", 800, 800);
   img->Draw("T100,100,yellow");
   //img->Draw("T100,100,#556655");
   //img->Draw("T100,100");

   TImage *i1 = TImage::Open("rose512.jpg");
   i1->SetConstRatio(kFALSE);
   i1->Flip(90);
   TImage *i2 = TImage::Open("rose512.jpg");
   i2->SetConstRatio(kFALSE);
   i2->Flip(180);
   TImage *i3 = TImage::Open("rose512.jpg");
   i3->SetConstRatio(kFALSE);
   i3->Flip(270);
   TImage *i4 = TImage::Open("rose512.jpg");
   i4->SetConstRatio(kFALSE);
   i4->Mirror(kTRUE);

   float d = 0.40;
   TPad *p1 = new TPad("i1", "i1", 0.05, 0.55, 0.05+d*i1->GetWidth()/i1->GetHeight(), 0.95);
   TPad *p2 = new TPad("i2", "i2", 0.55, 0.55, 0.95, 0.55+d*i2->GetHeight()/i2->GetWidth());
   TPad *p3 = new TPad("i3", "i3", 0.55, 0.05, 0.55+d*i3->GetWidth()/i3->GetHeight(), 0.45);
   TPad *p4 = new TPad("i4", "i4", 0.05, 0.05, 0.45, 0.05+d*i4->GetHeight()/i4->GetWidth());

   p1->Draw();
   p1->cd();
   i1->Draw();
   c->cd();

   p2->Draw();
   p2->cd();
   i2->Draw();
   c->cd();

   p3->Draw();
   p3->cd();
   i3->Draw();
   c->cd();

   p4->Draw();
   p4->cd();
   i4->Draw();
   c->cd();
}
开发者ID:My-Source,项目名称:root,代码行数:60,代码来源:img2pad.C

示例2: img2pad

void img2pad()
{
   TImage *img = TImage::Open("$ROOTSYS/tutorials/image/rose512.jpg");
   if (!img) {
      printf("Could not create an image... exit\n");
      return;
   }
   img->SetConstRatio(kFALSE);
   img->Draw("N");

   TCanvas *c = (TCanvas *)gROOT->GetListOfCanvases()->FindObject("rose512jpg");
   c->SetFixedAspectRatio();

   TCanvas *c1 = new TCanvas("roses", "roses", 800, 800);
   img->Draw("T100,100,#ffff00");
   /*img->Draw("T100,100,#556655");*/
   /*img->Draw("T100,100");*/

   TImage *i1 = TImage::Open("$ROOTSYS/tutorials/image/rose512.jpg");
   i1->SetConstRatio(kFALSE);
   i1->Flip(90);
   TImage *i2 = TImage::Open("$ROOTSYS/tutorials/image/rose512.jpg");
   i2->SetConstRatio(kFALSE);
   i2->Flip(180);
   TImage *i3 = TImage::Open("$ROOTSYS/tutorials/image/rose512.jpg");
   i3->SetConstRatio(kFALSE);
   i3->Flip(270);
   TImage *i4 = TImage::Open("$ROOTSYS/tutorials/image/rose512.jpg");
   i4->SetConstRatio(kFALSE);
   i4->Mirror(kTRUE);

   float d = 0.40;
   TPad *p1 = new TPad("i1", "i1", 0.05, 0.55, 0.05+d*i1->GetWidth()/i1->GetHeight(), 0.95);
   TPad *p2 = new TPad("i2", "i2", 0.55, 0.55, 0.95, 0.55+d*i2->GetHeight()/i2->GetWidth());
   TPad *p3 = new TPad("i3", "i3", 0.55, 0.05, 0.55+d*i3->GetWidth()/i3->GetHeight(), 0.45);
   TPad *p4 = new TPad("i4", "i4", 0.05, 0.05, 0.45, 0.05+d*i4->GetHeight()/i4->GetWidth());

   p1->Draw();
   p1->cd();
   i1->Draw();
   c1->cd();

   p2->Draw();
   p2->cd();
   i2->Draw();
   c1->cd();

   p3->Draw();
   p3->cd();
   i3->Draw();
   c1->cd();

   p4->Draw();
   p4->cd();
   i4->Draw();
   c1->cd();
}
开发者ID:Y--,项目名称:root,代码行数:57,代码来源:img2pad.C

示例3: plot_logo

   void plot_logo( Float_t v_scale = 1.0, Float_t skew = 1.0 )
   {

      TImage *img = findImage("tmva_logo.gif");
      if (!img) {
         cout << "+++ Could not open image tmva_logo.gif" << endl;
         return;
      }
      
      img->SetConstRatio(kFALSE);
      UInt_t h_ = img->GetHeight();
      UInt_t w_ = img->GetWidth();

      Float_t r = w_/h_;
      gPad->Update();
      Float_t rpad = Double_t(gPad->VtoAbsPixel(0) - gPad->VtoAbsPixel(1))/(gPad->UtoAbsPixel(1) - gPad->UtoAbsPixel(0));
      r *= rpad;

      Float_t d = 0.055;
      // absolute coordinates
      Float_t x1R = 1 - gStyle->GetPadRightMargin(); 
      Float_t y1B = 1 - gStyle->GetPadTopMargin()+.01; // we like the logo to sit a bit above the histo 

      Float_t x1L = x1R - d*r/skew;
      Float_t y1T = y1B + d*v_scale*skew;
      if (y1T>0.99) y1T = 0.99;

      TPad *p1 = new TPad("imgpad", "imgpad", x1L, y1B, x1R, y1T );
      p1->SetRightMargin(0);
      p1->SetBottomMargin(0);
      p1->SetLeftMargin(0);
      p1->SetTopMargin(0);
      p1->Draw();

      Int_t xSizeInPixel = p1->UtoAbsPixel(1) - p1->UtoAbsPixel(0);
      Int_t ySizeInPixel = p1->VtoAbsPixel(0) - p1->VtoAbsPixel(1);
      if (xSizeInPixel<=25 || ySizeInPixel<=25) {
         delete p1;
         return; // ROOT doesn't draw smaller than this
      }

      p1->cd();
      img->Draw();
   } 
开发者ID:CeF3TB,项目名称:BTFAnalysis,代码行数:44,代码来源:tmvaglob.C

示例4: draw_activation

void draw_activation(TCanvas* c, Double_t cx, Double_t cy, 
                     Double_t radx, Double_t rady, Int_t whichActivation)
{
   TImage *activation = NULL;

   switch (whichActivation) {
   case 0:
      activation = TImage::Open("sigmoid-small.png");
      break;
   case 1:
      activation = TImage::Open("line-small.png");
      break;
   default:
      cout << "Activation index " << whichActivation << " is not known." << endl;
      cout << "You messed up or you need to modify network.C to introduce a new "
           << "activation function (and image) corresponding to this index" << endl;
   }

   if (activation == NULL) {
      cout << "Could not create an image... exit" << endl;
      return;
   }
  
   activation->SetConstRatio(kFALSE);

   radx *= 0.7;
   rady *= 0.7;
   TString name = Form("activation%f%f", cx, cy);
   TPad* p = new TPad(name+"", name+"", cx-radx, cy-rady, cx+radx, cy+rady);

   p->Draw();
   p->cd();

   activation->Draw();
   c->cd();
}
开发者ID:TopBrussels,项目名称:TopTreeAnalysisBase,代码行数:36,代码来源:network.C

示例5: rose_image

void rose_image()
{
   // Display image in a new canvas and pad.

   TImage *img = TImage::Open("rose512.jpg");

   if (!img) {
      printf("Could not create an image... exit\n");
      return;
   }

   img->SetConstRatio(0);
   img->SetImageQuality(TAttImage::kImgBest);

   TString fp = gEnv->GetValue("Root.TTFontPath", "");
   TString bc = fp + "/BlackChancery.ttf";
   TString ar = fp + "/arial.ttf";

   // draw text over image with funny font
   img->DrawText(120, 160, "Hello World!", 32, 
                 gROOT->GetColor(4)->AsHexString(), 
                 bc, TImage::kShadeBelow);

   // draw text over image with foreground specified by pixmap
   img->DrawText(250, 350, "goodbye cruel world ...", 24, 0, 
                 ar, TImage::kPlain, "fore.xpm");

   TImage *img2 = TImage::Open("mditestbg.xpm");

   // tile image
   img2->Tile(img->GetWidth(), img->GetHeight());

   c1 = new TCanvas("rose512", "examples of image manipulations", 760, 900);
   c1->Divide(2, 3);
   c1->cd(1);
   img->Draw("xxx");
   img->SetEditable(kTRUE);

   c1->cd(2);
   // averaging with mditestbg.xpm image
   TImage *img3 = (TImage*)img->Clone("img3");
   img3->Merge(img2, "allanon");
   img3->Draw();

   // contrasting (tint with itself)
   c1->cd(3);
   TImage *img4 = (TImage*)img->Clone("img4");
   img4->Merge(img4, "tint");

   // draw filled rectangle with magenta color
   img4->FillRectangle("#FF00FF", 20, 220, 40, 40);

   // Render multipoint alpha-blended gradient (R->G->B)
   img4->Gradient(0, "#FF0000 #00FF00 #220000FF", 0, 50, 50, 100, 100);

   // draw semi-transparent 3D button
   img4->Bevel(300, 20, 160, 40, "#ffffffff", "#fe000000", 3, 0);
   img4->DrawLine(10, 100, 100, 10, "#0000ff", 4);
   img4->Draw();

   // vectorize image. Reduce palette to 256 colors
   c1->cd(4);
   TImage *img5 = (TImage*)img->Clone("img5");
   img5->Vectorize(256);
   img5->Draw();

   // quantization of the image
   c1->cd(5);
   TImage *img6 = (TImage*)img->Clone("img6");
   TImagePalette *pal = (TImagePalette *)&img5->GetPalette();
   TArrayD *arr = img6->GetArray(50, 40, pal);
   img6->SetImage(arr->GetArray(), 50, 40, pal);
   img6->Draw();

   // HSV adjustment (convert red to yellow)
   c1->cd(6);
   TImage *img7 = (TImage*)img->Clone("img7");
   img7->HSV(0, 40, 40);
   img7->Draw();
}
开发者ID:alcap-org,项目名称:AlcapDAQ,代码行数:80,代码来源:rose_image.C


注:本文中的TImage::SetConstRatio方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。