我有一个形象。我想从左边和从image.I的右10px的用下面的代码这样做C#:GDI +图片裁剪
string oldImagePath="D:\\RD\\dotnet\\Images\\photo1.jpg";
Bitmap myOriginalImage = (Bitmap)Bitmap.FromFile(oldImagePath);
int newWidth = myOriginalImage.Width;
int newHeight = myOriginalImage.Height;
Rectangle cropArea = new Rectangle(10,0, newWidth-10, newHeight);
Bitmap target = new Bitmap(cropArea.Width, cropArea.Height);
using (Graphics g = Graphics.FromImage(target))
{
g.DrawImage(myOriginalImage,cropArea);
}
target.Save("D:\\RD\\dotnet\\Images\\test.jpg");
裁切10像素但这不是给我我期望的结果。这将输出一个图像,它具有从右边裁剪10像素和调整大小的图像。替代裁剪,它将调整我认为的宽度。因此图像会缩小(按宽度)。任何人都可以纠正我吗?在此先感谢
以哪种方式不会给您预期的结果?你在看什么? – Chris 2009-06-23 01:57:21