McNeel Wiki
뷰와 화면 캡처
편집 · 인쇄 · 도움말 · 모든 항목
메뉴

AccuRender

Bongo

Brazil r/s

Flamingo

Penguin

Rhino 블로그

Rhino

Rhino Labs

검색

언어

Česky

Deutsch

English

Español

Français

Italiano

Polish

日本語

한국어

中文(繁體)

中文(简体)

 
.
Developer.NET
SummaryRhino SDK 를 사용하여 뷰와 화면을 이미지 파일로 캡처하는 방법을 소개합니다.

C# (Rhino 4)

  public override IRhinoCommand.result RunCommand(IRhinoCommandContext context)
  {
    MRhinoView view = RhUtil.RhinoApp().ActiveView();
    if (view == null)
      return IRhinoCommand.result.nothing;


    MRhinoGetOption go = new MRhinoGetOption();
    go.SetCommandPrompt("Capture Method");
    go.SetCommandPromptDefault("ViewCapture");
    int viewcap = go.AddCommandOption(new MRhinoCommandOptionName("ViewCapture"));
    int screencap = go.AddCommandOption(new MRhinoCommandOptionName("ScreenCapture"));
    go.GetOption();
    if( go.CommandResult() != IRhinoCommand.result.success )
      return go.CommandResult();


    System.Drawing.Bitmap bmp = null;


    if (go.Option().m_option_index == viewcap)
    {
      MRhinoDisplayPipeline pipeline = view.DisplayPipeline();
      int left = 0, right = 0, bot = 0, top = 0;
      view.MainViewport().VP().GetScreenPort(ref left, ref right, ref bot, ref top);
      int w = right - left;
      int h = bot - top;
      bmp = new System.Drawing.Bitmap(w, h);
      System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmp);
      MDisplayPipelineAttributes attr = new MDisplayPipelineAttributes(pipeline.DisplayAttrs());
      bool rc = pipeline.DrawToDC(g, w, h, attr);
      g.Dispose();
      if (!rc)
        bmp = null;
    }
    else
    {
      bmp = new System.Drawing.Bitmap(1, 1);
      bool rc = view.ScreenCaptureToBitmap(ref bmp, true, false);
      if (!rc)
        bmp = null;
    }


    if (bmp != null)
    {
      string mydir = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments);
      string path = System.IO.Path.Combine(mydir, "capture.png");
      bmp.Save(path);
      return IRhinoCommand.result.success;
    }


    return IRhinoCommand.result.failure;
  }
이름 바꾸기 · 변경 · 히스토리 · 구독 · 찾기 · 참조 · 파일 업로드