zoukankan      html  css  js  c++  java
  • 用网页显示图片的方法

    方法一、显示原图

    using System;

    namespace DtCms.Web.Tools
    {
        public partial class img : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                string gurl = "/UpLoadFiles/20110117/2011011719440778.jpg";
                Response.ContentType = "image/jpg";
                Response.Clear();
                Response.WriteFile(gurl);
            }

        }
    }

    方法二、二进制显示原图

    using System;
    using System.IO;

    namespace DtCms.Web.Tools
    {
        public partial class httpimg : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                string filePath = "图片路径";
                Response.ContentType = "image/jpg";
                FileStream imageStr = new FileStream(filePath, FileMode.Open);
                byte[] imageData = new byte[imageStr.Length];
                imageStr.Read(imageData, 0, (int)imageStr.Length);
                Response.OutputStream.Write(imageData, 0, (int)imageStr.Length);  

            }
        }
    }

  • 相关阅读:
    删除链表的倒数第N个节点(java实现)
    Java多线程之volatile关键字《一》
    Utils
    分布式和集群
    java RMIC
    Log4j输出终端(Appender)详解
    使用存储过程并返回值与及返回值的获得方法
    groupBy
    group by java实现
    本机Font字体
  • 原文地址:https://www.cnblogs.com/sntetwt/p/2011187.html
Copyright © 2011-2022 走看看