图片在网页里实现缩列图,图片会变形,有什么办法可以解决么?

vcinsect 2004-08-25 12:00:24
图片在网页里实现缩列图,图片会变形,有什么办法可以解决么?
...全文
161 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
walkinhill 2004-08-25
  • 打赏
  • 举报
回复
采用 image.GetThumbnailImage 方法就不会出现变形了,因为该函数会自动补充空格
walkinhill 2004-08-25
  • 打赏
  • 举报
回复
'Éú³ÉËõÂÔͼ
Protected Shared Function SaveThumbnail(ByVal fromfile As String)
Dim image, anewimage As System.Drawing.Image
Dim width, height, newwidth, newheight As Integer
Dim callb As System.Drawing.Image.GetThumbnailImageAbort
Dim SmallFileFullName As String
Dim filepath As String
filepath = Path.GetDirectoryName(fromfile)
Dim FileName As String
FileName = Path.GetFileName(fromfile)
image = System.Drawing.Image.FromFile(fromfile)
width = image.Width
height = image.Height
If width > height Then
newwidth = 100
newheight = image.Height / image.Width * newwidth
Else
newheight = 100
newwidth = image.Width / image.Height * newheight
End If
anewimage = image.GetThumbnailImage(newwidth, newheight, callb, New System.IntPtr)
Dim smallphotopath As String = filepath + "\smallphoto\"
If Not Directory.Exists(smallphotopath) Then
Directory.CreateDirectory(smallphotopath)
End If
SmallFileFullName = smallphotopath + FileName
anewimage.Save(SmallFileFullName)
image.Dispose()
End Function
lsdys 2004-08-25
  • 打赏
  • 举报
回复
只设宽度或高度

62,074

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧