asp.net 2。0图片 操作方式,剪切,

来源:互联网 发布:英雄连德国知乎 编辑:程序博客网 时间:2024/06/07 01:05

public void Clone_Output(int x, int y, int w, int h, string imgname, string ok)
    {
        Bitmap myBitmap = new Bitmap(Server.MapPath("~/") + imgname);
        Bitmap sltimg = new Bitmap(myBitmap, w, h);
        Rectangle cloneRect = new Rectangle(x, y, 142, 168);
        System.Drawing.Imaging.PixelFormat format = myBitmap.PixelFormat;
        Bitmap cloneBitmap = sltimg.Clone(cloneRect, format);
        cloneBitmap.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
        if (ok == "yes")
        {
            cloneBitmap.Save(Server.MapPath("~/") + "clone_" + imgname);
        }
        myBitmap.Dispose();
        sltimg.Dispose();
        cloneBitmap.Dispose();
    } 

原创粉丝点击