-1

有没有办法以编程方式从 JPG 图像中删除 JPG 图像(矩形)的一部分。通过一些试验和错误,我可以调整 XY 坐标以适应我的要求(剪切用户名框)

所有的问题似乎都需要裁剪的矩形部分,而我需要将矩形药水空白的原始图像。

4

1 回答 1

1

此示例代码采用图像的右下象限。与您合作并获得一个想法应该足够了::

string path = "C:\\test.jpg";
using (Bitmap orignal = new Bitmap(path))
{
        using (Bitmap newimage = new Bitmap((int)(orignal.Width * 0.5), (int)(orignal.Height * 0.5)))
        {
                using (Graphics newgraphics = Graphics.FromImage(newimage))
                {
                        newgraphics.DrawImage(orignal, 0, 0, new Rectangle(newimage.Width, newimage.Height, orignal.Width - newimage.Width, orignal.Height - newimage.Height), GraphicsUnit.Pixel);
                        newgraphics.Flush();
                }


                newimage.Save(new System.IO.FileInfo(path).DirectoryName + "out.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
        }
}
于 2013-02-22T05:58:01.183 回答