开发者

Write to hDC with GDI+ in C#

I have a int which represents the hDC handle of my display.

How can I draw a bitmap the the display in C#? Feel free to be as broad or as specific as you want. I'm not really clear 开发者_如何学Chow to proceed and all advice is appreciated.

This will eventually be an ArcEngine layer interface.

public class CustomLayer : ILayer
{

public void Draw(esriDrawPhase DrawPhase, IDisplay Display, ITrackCancel TrackCancel)
{
  int hdc = Display.hDC;
  //how to draw a bitmap?
}


}


Graphics.FromHdc(hdc)

This gives you a nice .NET graphics object with good capability.

var graphics = Graphics.FromHdc(hdc);

// Create image.
Image newImage = Image.FromFile("Swans.bmp");

// Create Point for upper-left corner of image.
Point ulCorner = new Point(0, 0);

// Draw image to screen.
graphics.DrawImage(newImage, ulCorner);

More info here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜