請問如果在一個PictureBox 控制項中載入一張大圖,
那麼如何擷取PictureBox 部分的區域到另一個PictureBox2 控制項中呢?
例如PictureBox 是900*900,而PictureBox2 只會顯示從位置x=200,y=100的地方開始抓起,
並抓出300*300的大小圖出來顯示?
StartPiont = (200, 100)
CutArea = (0,0,300,300)
<pre class="c" name="code">
private Image CutImage(Image SourceImage, Point StartPoint, Rectangle CutArea)
{
Bitmap NewBitmap = new Bitmap(CutArea.Width, CutArea.Height);
Graphics tmpGraph = Graphics.FromImage(NewBitmap);
tmpGraph.DrawImage(SourceImage, CutArea, StartPoint.X, StartPoint.Y, CutArea.Width, CutArea.Height, GraphicsUnit.Pixel);
tmpGraph.Dispose();
return NewBitmap;
}