作爲我之前提到的問題,我得到了我的區域,但花了最後兩個小時試圖顯示單獨拍攝該區域的小圖片;最終目標是能夠任意顯示我選擇的任意數量的圖像。 到目前爲止,這是我的代碼:如何在Picturebox中定義的區域內顯示圖像?
void OnPaintRadar(Object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
Bitmap blip = new Bitmap(tst_Graphics.Properties.Resources.dogtag);
Rectangle radar_rect = new Rectangle(myRadarBox.Left + 80, myRadarBox.Left + 7, myRadarBox.Width - 200, myRadarBox.Height + 200);
using (Pen drw_pen = new Pen(Color.White, 1))
{
using (GraphicsPath path = new GraphicsPath())
{
path.AddPie(radar_rect, 180, 180);
path.CloseFigure();
using (Region rdRegion = new Region(path))
{
g.DrawPath(drw_pen, path);
g.Clip = rdRegion;
PictureBox pb = new PictureBox();
pb.Image = (blip);
pb.Size = blip.Size;
g.DrawImage(blip, radar_rect);
}
}
}
}// end paint method
我已經試過DrawImageUnscaled方法還,但我要麼得到我的小圖片吹填補了餡餅區域或不顯示任何內容。
非常感謝。我會看看它,稍後再回復你。 – 2009-08-24 12:23:44