zoukankan      html  css  js  c++  java
  • 截图片

     public static Image CutImage(Image img, int width, int height)
            {
                Bitmap image 
    = new Bitmap(img);

                
    int calheight = width * image.Height / image.Width;
                
    int calwidth = height * image.Width / image.Height;

                Image img2;

                
    if (calheight >= height)
                {
                    img2 
    = image.GetThumbnailImage(width, calheight, null, IntPtr.Zero);
                }
                
    else
                {
                    img2 
    = image.GetThumbnailImage(calwidth, height, null, IntPtr.Zero);
                }

                Bitmap bitmap 
    = new Bitmap(img2);
                
    int x = (bitmap.Width - width) / 2;
                
    int y = (bitmap.Height - height) / 2;
                Rectangle cloneRect 
    = new Rectangle(x, y, width, height);
                PixelFormat format 
    = bitmap.PixelFormat;
                Bitmap cloneBitmap 
    = bitmap.Clone(cloneRect, format);

                
    return cloneBitmap;

            }
  • 相关阅读:
    使用jmeter和fidder进行APP接口测试
    测试模板积累
    功能测试-
    Django 路由
    Django 基础
    JQ 简单动画显示隐藏效果
    JQ $.each详解
    JQ 事件绑定与事件委派
    django模板之forloop
    JQ 属性操作
  • 原文地址:https://www.cnblogs.com/gateluck/p/1986197.html
Copyright © 2011-2022 走看看