zoukankan      html  css  js  c++  java
  • Asp.net C# 图像处理

      在aspx页面添加一个Image控件,其ImageUrl="Image.aspx",
                添加一个Image.aspx,专门用来处理图像,在cs代码里的Page_Load事件处理中写上如下代码:

                //原始图像
                string physicalPath = Server.MapPath("./129519.jpg");
                System.Drawing.Image srcBitmap = Bitmap.FromFile(physicalPath);
                //想要的目标图像
                int outHeight = srcBitmap.Height * 2;
                int outWidth = srcBitmap.Width * 2;
                //先创建一个空白的Bitmap
                Bitmap outBitmap = new Bitmap(outWidth, outHeight, PixelFormat.Format24bppRgb);
                Graphics g = Graphics.FromImage(outBitmap);
                //在outBitmap 上绘图
                Rectangle destRectangle=new Rectangle(0, 0, outWidth, outHeight);
                int srcX = 0;
                int srcY = 0;
                g.DrawImage(srcBitmap, destRectangle/*显示图像的大小*/, srcX,srcY/*从此X,Y坐标开始截取*/,srcBitmap.Width/4/*截取宽*/, srcBitmap.Height/4/*截取高*/, GraphicsUnit.Pixel);
             
                //设置输出类型
                Response.ContentType = "image/jpeg";
                //向Client 输出
                outBitmap.Save(Response.OutputStream, ImageFormat.Jpeg);
                Response.End();
  • 相关阅读:
    ImportError: libgthread-2.0.so.0: cannot open shared object file: No such file or directory
    pycocotools使用教程
    with torch.no_grad() 详解
    虚拟机Ubuntu上下载Pytorch显示超时
    Deep Layer Aggregation DLA网络的结构
    tgz文件解压命令
    install mysql at linux
    devops issue
    process data
    unittest
  • 原文地址:https://www.cnblogs.com/platfarm/p/3907895.html
Copyright © 2011-2022 走看看