ASPNET中图片显示方法实例
来源:诚信在线    发布时间:2017-07-06 23:44:44

  using System.Web.SessionState;

  // 'thumbnail' means we are requesting a thumbnail

  { get { return true; } }

  public bool IsReusable

  thumb.Save(Context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);

  }

  thumb.Dispose();

  public void ProcessRequest(HttpContext Context)

  using System.Data;

  float scale = 150.0f / System.Math.Max(bmp.Height, bmp.Width);

  genimage.ashx.cs:

  public class ImageGenerator : IHttpHandler

  }

  // You may obtain a copy of the License at:

  const int byteLength = 8192;

  使用方法:

  你大概感兴趣的文章:Asp.net FileUpload+Image制造头像动机示例代码asp.net表现图片到指定的Image控件外 详细完成asp.net考证码图片天生示例ASP.NET完成图片以二进制的模式存入数据库运用asp.net改动网页上图片色彩比方灰色变彩色应用asp.net扭转图片色彩如灰色的变为彩色Asp.net容易完成给图片添加笔墨水印ASP.NET容易美勤奋能齐备图片上传对象类(水印、缩略图、裁剪等)Asp.Net上传图片同时天生下清楚缩略图asp.net文件上传解决方案(图片上传、单文件上传、多文件上传、反省文件类型)ASP.NET图片处置惩罚3类经典成绩asp.net fileupload控件上传图片并预览图片ASP.NET图片上传实例(附源码)ASP.NET完成上传图片并天生缩略图的法子asp.net完成图片以二进制流输出的二种要领ASP.NET外Image控件利用详解

  using System.Configuration;

  using System.Drawing;

  //图片门路 

  int picid = Convert.ToInt32(Context.Request["id"]);

  System.IO.FileStream fs = File.Open(imgpath, FileMode.Open, FileAccess.Read, FileShare.Read);

  //

  // (mailto:)

  using System.Collections;

  using System.Web.UI.WebControls;

  npdata.SetNumViews(picid, numviews+一);

  {

  }

  int numviews;

  System.Drawing.Image thumb = bmp.GetThumbnailImage((int)(bmp.Width * scale), (int)(bmp.Height * scale), null, System.IntPtr.Zero);

  //图片涉猎次数

  using System.Web.UI.HtmlControls;

  // You may not use this file except in compliance with the License.

  //表现缩略图

  using System.Web;

  //图片数据库中的ID

  本文实例报告了ASP.NET外图片的显现法子。分享给人人求人人参考。详细以下:

  using System.ComponentModel;

  using System.Web.UI;

  Context.Response.ContentType = "image/jpg";

  {

  //更新数据库涉猎次数

  //

  {

  using System.Data.SqlClient;

  // Copyright (C) 2003 by Greg Ennis

  using System;

  // Get the stream and send it out the response

  复制代码 代码以下:

  else

  // Stream directly from the file

  }

  fs.Close();

  while( fs.Read(bytes, 0, byteLength ) != 0 )

  // Need to load the image, resize it, and stream to the client.

  if (Context.Request["thumbnail"] != null)

  {

  namespace netpix

  // Writing an image to output stream

  genimage.ashx:

  using System.IO;

  byte[] bytes = new byte[byteLength];

  }

  期望本文所述对于各人的ASP.NET程序设计有所赞助。

  bmp.Dispose();

  // The contents of this file are subject to the Artistic License (the "License").

  Context.Response.BinaryWrite(bytes);

  {

  // Calculate the scale so as not to stretch or distort the image.

  Bitmap bmp = new Bitmap(imgpath);

  复制代码 代码以下:imgCtrl.ImageUrl = "genimage.ashx?id=" + Request["id"];

  {

  }

  // Get the image filename and album root path from the database

  string imgpath = npdata.GetPathToPicture(picid, out numviews);


诚信在线 除注明原创以外,其余均来自互联网以及微信朋友圈,如有侵权请联系站长立即删除!
文章地址:http://www.my517517.com/YY/20170706436.html



上一篇:微信小程序新增的拖动组件movable 下一篇:javascript相等运算符与等同运算符详细介绍