我想在c#代碼中多切一張圖片。以下圖片是我的c#論壇,我可以選擇一個區域並剪切它。如何在c#中多次剪切一張圖片?
我想要將多個切割在C#代碼 一個畫面欲重複這個過程 私人無效btnKes_Click(對象發件人,EventArgs的) { INT tiklanma = 0; (true) { tiklanma ++; } pictureBox2.Refresh();
pictureBox2.Refresh();
Bitmap sourceBitmap = new Bitmap(pictureBox1.Image, pictureBox1.Width, pictureBox1.Height);
Graphics g = pictureBox2.CreateGraphics();
int x1, x2, y1, y2;
Int32.TryParse(txtX1.Text, out x1);
Int32.TryParse(txtX2.Text, out x2);
Int32.TryParse(txtY1.Text, out y1);
Int32.TryParse(txtY2.Text, out y2);
if ((x1 < x2 && y1 < y2))
{
rectCropArea = new Rectangle(x1, y1, x2 - x1, y2 - y1);
}
else if (x2 < x1 && y2 > y1)
{
rectCropArea = new Rectangle(x2, y1, x1 - x2, y2 - y1);
}
else if (x2 > x1 && y2 < y1)
{
rectCropArea = new Rectangle(x1, y2, x2 - x1, y1 - y2);
}
else
{
rectCropArea = new Rectangle(x2, y2, x1 - x2, y1 - y2);
}
pictureBox1.Refresh(); // This repositions the dashed box to new location as per coordinates entered.
int sayac = 40;
for (int i = 0; i < tiklanma; i++)
{
PictureBox pcBx = new PictureBox();
Size size = new Size(100, 100);
pcBx.Location();
pcBx.Size = size;
g.DrawImage(sourceBitmap, new Rectangle(0, 0, rectCropArea.Width, rectCropArea.Height), rectCropArea, GraphicsUnit.Pixel);
}
sourceBitmap.Dispose();
}
我想在第二張圖片中多次選擇字段並保存字段。我怎樣才能做到這一點?
[so]是*不*免費代碼寫作服務。預計你會嘗試**自己編寫代碼**。在[做更多研究]之後(http://meta.stackoverflow.com/questions/261592),如果你有問題,你可以**發佈你已經嘗試過**的清單,說明什麼是不工作的**並提供** [mcve] **。我建議閱讀[問]一個好問題和[完美問題](http://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/)。另外,一定要參加[旅遊]。 – Igor