在Mysql的数据库中,图片是以磁盘路径地址的格式保存,现在想在网页中把数据库中的数据地址以图片的形式展示出来,用什么控件,方法怎么写,才可以做到?
解决方案 »
- 用在纯Html上的ewebeditor,总是取不到值 ,这是为什么?
- asp.net用Fileupload上传图片问题
- Windows Server 2008 IIS 视频不能播放【急急】
- 请教个问题,如何设置某些网页只能在iframe中调用,而不能直接访问?
- 关于dropdownlist
- 使用datagrid模板列怎么显示自定义的字段?
- 怎样将filestream中的图形放到网页上?
- repeater下绑定了hyperlink,最后一项绑定不了链接,求解释
- 请问怎样使用oledbdataadapter向数据库插入记录?
- 求助!导出ecexl表格如何序号自增长!?
- asp.net中关闭页网时触发的事件
- asp.net网站主页被加恶意链接
如果是的 那么直接img就可以了 至于你说的略缩 偷懒的话 直接给img标签大小 如果要做到真正的略缩 需要代码处理一下.
参考代码:using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;/// <summary>
///PubClass 的摘要说明
/// </summary>
public class PubClass
{
public PubClass()
{
} #region##对给定的一个图片(Image对象)生成一个指定大小的缩略图
///<summary>
/// 对给定的一个图片(Image对象)生成一个指定大小的缩略图。
///</summary>
///<param name="originalImage">原始图片</param>
///<param name="thumMaxWidth">缩略图的宽度</param>
///<param name="thumMaxHeight">缩略图的高度</param>
///<returns>返回缩略图的Image对象</returns>
public static System.Drawing.Image GetThumbNailImage(System.Drawing.Image originalImage, int thumMaxWidth, int thumMaxHeight)
{
System.Drawing.Size thumRealSize = System.Drawing.Size.Empty;
System.Drawing.Image newImage = originalImage;
System.Drawing.Graphics graphics = null;
try
{
thumRealSize = GetNewSize(thumMaxWidth, thumMaxHeight, originalImage.Width, originalImage.Height);
newImage = new System.Drawing.Bitmap(thumRealSize.Width, thumRealSize.Height);
graphics = System.Drawing.Graphics.FromImage(newImage);
graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
graphics.Clear(System.Drawing.Color.Transparent);
graphics.DrawImage(originalImage, new System.Drawing.Rectangle(0, 0, thumRealSize.Width, thumRealSize.Height), new System.Drawing.Rectangle(0, 0, originalImage.Width, originalImage.Height), System.Drawing.GraphicsUnit.Pixel);
}
catch { }
finally
{
if (graphics != null)
{
graphics.Dispose();
graphics = null;
}
}
return newImage;
}
#endregion #region##获取一个图片按等比例缩小后的大小
///<summary>
/// 获取一个图片按等比例缩小后的大小。
///</summary>
///<param name="maxWidth">需要缩小到的宽度</param>
///<param name="maxHeight">需要缩小到的高度</param>
///<param name="imageOriginalWidth">图片的原始宽度</param>
///<param name="imageOriginalHeight">图片的原始高度</param>
///<returns>返回图片按等比例缩小后的实际大小</returns>
public static System.Drawing.Size GetNewSize(int maxWidth, int maxHeight, int imageOriginalWidth, int imageOriginalHeight)
{
double w = 0.0;
double h = 0.0;
double sw = Convert.ToDouble(imageOriginalWidth);
double sh = Convert.ToDouble(imageOriginalHeight);
double mw = Convert.ToDouble(maxWidth);
double mh = Convert.ToDouble(maxHeight);
if (sw < mw && sh < mh)
{
w = sw;
h = sh;
}
else if ((sw / sh) > (mw / mh))
{
w = maxWidth;
h = (w * sh) / sw;
}
else
{
h = maxHeight;
w = (h * sw) / sh;
}
return new System.Drawing.Size(Convert.ToInt32(w), Convert.ToInt32(h));
}
#endregion #region##删除文件
/// <summary>
/// 删除文件
/// </summary>
/// <param name="path"></param>
public static void FileDel(string path)
{
if (System.IO.File.Exists(path))
{
System.IO.File.Delete(path);
}
}
#endregion
}
如果是的 那么直接img就可以了 至于你说的略缩 偷懒的话 直接给img标签大小 如果要做到真正的略缩 需要代
恩 是的 就是想把数据库存的图片地址 用图片显示出来 ?
用Image空间怎么实现 谢谢(所略图先不考虑)
在前台页面用JS接收这个路径//保存用户条件
var path= "<%=path%>";然后<img src=path></img>或者直接<img src='<%=path%>'></img>