YouTube | Facebook | X(Twitter) | RSS

クリップボードにマップのグラフィックをコピー

2016/9/1 (木)

// http://forums.esri.com/Thread.asp?c=159&f=1707&t=268556
private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
{
      IRubberBand pRubberPoly = new ESRI.ArcGIS.Display.RubberEnvelopeClass();
      IEnvelope myenv = pRubberPoly.TrackNew(this.axMapControl1.ActiveView.ScreenDisplay, null).Envelope ;
      double yokoratio;
      double tateratio;
      int w;
      int h;
       
      yokoratio = myenv.Width/this.axMapControl1.ActiveView.Extent.Width;
      tateratio = myenv.Height/this.axMapControl1.ActiveView.Extent.Height;
 
      w = (int)(axMapControl1.ClientSize.Width * yokoratio);
      h = (int)(axMapControl1.ClientSize.Height * tateratio);
 
 
      IActiveView activeView = this.axMapControl1.ActiveView;
      Bitmap bitmap = new Bitmap(w,h);
      Graphics graphics = Graphics.FromImage(bitmap);
  
 
      ESRI.ArcGIS.Display.tagRECT rect = new ESRI.ArcGIS.Display.tagRECT();
      ESRI.ArcGIS.Display.tagRECT nowrect = new ESRI.ArcGIS.Display.tagRECT();
 
      rect.left = 0;
      rect.top = 0;
      rect.bottom = bitmap.Height;
      rect.right = bitmap.Width;
 
 
      IEnvelope myenv2 = activeView.Extent;
      myenv2.Expand(0.5, 0.5, true);
      IntPtr hDC = graphics.GetHdc();
      activeView.Output(hDC.ToInt32(), 0, ref rect, myenv, null);
      graphics.ReleaseHdc(hDC);
      graphics.Dispose();
 
      Clipboard.SetImage(bitmap);
       
}

関連記事

  • この記事を書いた人

羽田 康祐

伊達と酔狂のGISエンジニア。GIS上級技術者、Esri認定インストラクター、CompTIA CTT+ Classroom Trainer、潜水士、PADIダイブマスター、四アマ。WordPress は 2.1 からのユーザーで歴だけは長い。 代表著書『地図リテラシー入門―地図の正しい読み方・描き方がわかる』 GIS を使った自己紹介はこちら。ESRIジャパン(株)所属、元青山学院大学非常勤講師を兼務。日本地図学会第31期常任委員。発言は個人の見解です。

-プログラミング, ArcGIS
-,

WINGFIELD since1981をもっと見る

今すぐ購読し、続きを読んで、すべてのアーカイブにアクセスしましょう。

続きを読む