我使用SharpZipLib压缩和解压图片,压缩后的压缩包是没有问题的,但是解压后图片有损失,有没有人有这方面的经验的人告诉一下是什么原因造成的。
解决方案 »
- datalist编辑删除的问题
- [100分]-_-!神码!!!请JS达人讲解!!!!!!!!!!!!!!!
- ASP.NET中gridview控件一条记录显示数据库中多条记录?
- 问一个设计方面的问题
- 如何检查客户端的浏览器是否安装了.net运行环境?
- 两个表的结果一摸一样。如何实现一个表中的内容copy到另外一个表中。。
- 人为设置让web api参数反序列化为json
- 关于使用AJAX中实现DataGrid无刷新数据绑定中使用AjaxHelper问题的请教?
- 为什么权限不够?
- 请问在Visual InterDev 6.0中建立工程出现的问题?
- 做的一个站,在本机上一切正常,但上传到服务器后,按钮提交后不能正常返回
- asp.net用户登陆小问题!!!!!!!!!!!
public void reDrawSaveImage(System.IO.Stream imgStream,string savePath,int upWidth,int upHeight)
{
int oldWidth;
int oldHeight;
int newWidth;
int newHeight; newWidth = upWidth;
newHeight = upHeight; System.Drawing.Image oldImg = System.Drawing.Image.FromStream(imgStream); oldWidth = oldImg.Width;
oldHeight = oldImg.Height; if(oldWidth >= oldHeight)
{
newHeight = (int)Math.Floor(Convert.ToDouble(oldHeight) * Convert.ToDouble(newWidth) / Convert.ToDouble(oldWidth));
}
else
{
newWidth = (int)Math.Floor(Convert.ToDouble(oldWidth) * Convert.ToDouble(newHeight) / Convert.ToDouble(oldHeight));
} Bitmap newImg = new Bitmap(newWidth,newHeight);
Graphics g = Graphics.FromImage(newImg);
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High; //设置高质量插值法
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;//设置高质量,低速度呈现平滑程度
g.Clear(Color.Transparent); //清空画布并以透明背景色填充
g.DrawImage(oldImg,new Rectangle(0,0,newWidth,newHeight),new Rectangle(0,0,oldWidth,oldHeight),GraphicsUnit.Pixel);
newImg.Save(savePath,System.Drawing.Imaging.ImageFormat.Jpeg); g.Dispose();
oldImg.Dispose();
newImg.Dispose(); }