日期:2014-05-18  浏览次数:20450 次

上传图片时GIF的图片(不是动画)能生成缩略图吗?能DrawString吗?
上传图片时GIF的图片(不是动画)能生成缩略图吗?能DrawString吗?

------解决方案--------------------
if (inputFile.PostedFile.ContentLength < 1024 * 300)
{
System.Drawing.Image.GetThumbnailImageAbort backb = null;
//大图
string fullName = inputFile.PostedFile.FileName;
string newName = System.DateTime.Now.ToString( "yyyyMMddhhmmss ") + fullName.Substring(fullName.LastIndexOf( ". "));
string path = Server.MapPath( "PlayerPhotos ");
inputFile.SaveAs(path + "/ " + newName);
labelUpResult.Text = newName;
//缩略图
System.Drawing.Image image = System.Drawing.Image.FromFile(Server.MapPath( "PlayerPhotos/ " + newName));
System.Drawing.Image newimage = image.GetThumbnailImage(106, 106, backb, IntPtr.Zero);
newimage.Save(Server.MapPath( "PlayerPhotos ") + "/s/ " + newName);
image.Dispose();
ifSucess = true;
}
else
{
Response.Write( " <script> alert( '出错了!上传文件太大! ') </script> ");
}
------解决方案--------------------
呵呵,原来是要代码啊。
可惜我现在没有.NET环境,大概思路可以告诉你
查询一下绘图类,不过我不记得.NET有没有提供图象大小变换的方法,如果没有你可能要去寻找下这个算法的代码了。希望提供了。然和读入图象就可以使用drawstring绘制文字等等操作了。