1

我有 2 个 picutrebox,我正在将加载的图像复制到另一个,但是我的代码复制速度太慢,当我删除Refresh();它时,它会立即出现,我想让延迟比刷新时更快

这是代码

    private void buttonClone_Click(object sender, EventArgs e)
    {

        if (pictureBoxSourcePicture.Image == null)
        {
            MessageBox.Show("No pictuer loaded");
            return;
        }
        Bitmap clonePic = new Bitmap(pictureBoxSourcePicture.Image.Width, pictureBoxSourcePicture.Image.Height);
        Bitmap sourcePic = new Bitmap(pictureBoxSourcePicture.Image);

        for (int x = 0; x < pictureBoxSourcePicture.Image.Width; x++)
        {
            for (int y = 0; y < pictureBoxSourcePicture.Image.Height; y++)
          {

              clonePic.SetPixel(x, y, sourcePic.GetPixel(x, y));
              pictureBoxTarget.Image = clonePic;
              pictureBoxTarget.Refresh();
              //pictureBoxSourcePicture.Image.Clone();
          }
        }
    }
4

0 回答 0