Image img=new Bitmap(@"D:/getphoto/GetPic/ad.bmp");
Bitmap originalBMP = new Bitmap(@"D:/getphoto/GetPic/ad.bmp");
Bitmap bmpcropped = new Bitmap(img,rc.Size);//rc.Width,rc.Height //(Convert.ToInt32((lowerRightX - upperLeftX).ToString()),
int iH,iV;
for(iH=0;iH<rc.Width;iH++) //rc.Width截取图片的宽
{
for(
iV=0;iV<rc.Height;iV++) //rc.Height截取图片的高
{
bmpcropped.SetPixel (iH,iV,originalBMP.GetPixel(iH+rc.X,iV+rc.Y));
}
}
this.pictureBox1.Image = bmpcropped; //显示截取的图片
bmpcropped.Save(outpath);
Bitmap originalBMP = new Bitmap(@"D:/getphoto/GetPic/ad.bmp");
Bitmap bmpcropped = new Bitmap(img,rc.Size);//rc.Width,rc.Height //(Convert.ToInt32((lowerRightX - upperLeftX).ToString()),
int iH,iV;
for(iH=0;iH<rc.Width;iH++) //rc.Width截取图片的宽
{
for(
iV=0;iV<rc.Height;iV++) //rc.Height截取图片的高
{
bmpcropped.SetPixel (iH,iV,originalBMP.GetPixel(iH+rc.X,iV+rc.Y));
}
}
this.pictureBox1.Image = bmpcropped; //显示截取的图片
bmpcropped.Save(outpath);