public static Bitmap CropBitmap(Bitmap bitmap, int cropX, int cropY, int cropWidth, int cropHeight)        

{            

      Rectangle rect = new Rectangle(cropX, cropY, cropWidth, cropHeight);   

      Bitmap cropped = bitmap.Clone(rect, bitmap.PixelFormat);   

     return cropped;      

   }

        static void  Main(string[] args)       

  {         

      string path = "c:\\temped";         

      DirectoryInfo dic = new DirectoryInfo(path);          

      FileInfo[] files =  dic.GetFiles().OrderBy(item=>item.CreationTime).ToArray();      

       foreach (FileInfo item in files)          

     {           

           if (item.Extension == ".bmp")     

            {                   

                      string name = item.FullName;   

                      Image im = Image.FromFile(item.FullName);      

                       Bitmap bt = new Bitmap(im);                   

                      im.Dispose();                 

                         Bitmap newBit = CropBitmap(bt, 52, 62, 253, 249);   

                         File.Delete(item.FullName);                  

                         newBit.Save(name);                        

                  }

            }

}

相关文章:

  • 2022-12-23
  • 2021-08-03
  • 2022-12-23
  • 2022-12-23
  • 2021-12-23
  • 2022-02-18
  • 2021-08-24
猜你喜欢
  • 2021-09-06
  • 2021-08-15
  • 2021-12-04
  • 2022-02-25
  • 2022-12-23
  • 2021-07-02
  • 2022-12-23
相关资源
相似解决方案