• C# 图像截取


     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);                        

                      }

                }

    }

  • 相关阅读:
    桥接,NAT,Host Only的区别
    PHP并发IO编程之路
    Git SSH Key 生成步骤
    composer安装学习
    db file sequential read等待事件的一点研究
    多个hints 怎么写?
    再次遭遇笛卡尔积
    pl/sql 在一个程序块里打印日志输出到表格
    pl/sql 程序块里打印问题
    利用ordered hints优化SQL
  • 原文地址:https://www.cnblogs.com/liuxinls/p/2870280.html
Copyright © 2020-2023  润新知