//获取图片名称
imagename=ImageSource.ImageUrl.Substring(this.ImageSource.ImageUrl.LastIndexOf("\\")+1);
//为图片建立引用
Image=System.Drawing.Image.FromFile(Server.MapPath(this.ImageSource.ImageUrl));
//生成缩略图
NewImage=Image.GetThumbnailImage(100,100,null,IntPtr.Zero);
//保存缩略图在虚拟路径上
NewImage.Save(Request.PhysicalApplicationPath+"small\\"+imagename);
this.Label1.Text =Request.PhysicalApplicationPath+"small\\"+imagename;//Request.PhysicalApplicationPath+this.ImageSource.ImageUrl;
//释放空间
Image.Dispose();
NewImage.Dispose();
//显示缩略图
Image1.ImageUrl =Server.MapPath(this.ImageSource.ImageUrl);
//dr.NextResult;
dr.Close();
sqlCon.Close();
请问我在代码里面有错误吗?
为什么我生成缩略图以后,到small这个文件夹里找这个图片的时候是一个x,什么也看不了?????
imagename=ImageSource.ImageUrl.Substring(this.ImageSource.ImageUrl.LastIndexOf("\\")+1);
//为图片建立引用
Image=System.Drawing.Image.FromFile(Server.MapPath(this.ImageSource.ImageUrl));
//生成缩略图
NewImage=Image.GetThumbnailImage(100,100,null,IntPtr.Zero);
//保存缩略图在虚拟路径上
NewImage.Save(Request.PhysicalApplicationPath+"small\\"+imagename);
this.Label1.Text =Request.PhysicalApplicationPath+"small\\"+imagename;//Request.PhysicalApplicationPath+this.ImageSource.ImageUrl;
//释放空间
Image.Dispose();
NewImage.Dispose();
//显示缩略图
Image1.ImageUrl =Server.MapPath(this.ImageSource.ImageUrl);
//dr.NextResult;
dr.Close();
sqlCon.Close();
请问我在代码里面有错误吗?
为什么我生成缩略图以后,到small这个文件夹里找这个图片的时候是一个x,什么也看不了?????
Image1.ImageUrl =Server.MapPath(this.ImageSource.ImageUrl);
这两段代码只是测试路径,不关事的。
destTmp是你要保存的路径
System.Drawing.Image.GetThumbnailImageAbort myCallback = new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);System.Drawing.Image bigImage = img.GetThumbnailImage(400,300,myCallback,IntPtr.Zero);
bigImage.Save(destTmp,System.Drawing.Imaging.ImageFormat.Jpeg);public bool ThumbnailCallback()
{
return false;
}
FileInfo fi = new FileInfo(tmp);
System.Drawing.Image img = System.Drawing.Image.FromStream(imgstream);
Stream imgstream = fi.OpenRead()
忘记了一段代码了,不好意思