惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Vulnerabilities – Threatpost
T
The Blog of Author Tim Ferriss
S
SegmentFault 最新的问题
D
DataBreaches.Net
博客园_首页
罗磊的独立博客
B
Blog
T
Threat Research - Cisco Blogs
C
Cisco Blogs
GbyAI
GbyAI
Engineering at Meta
Engineering at Meta
WordPress大学
WordPress大学
G
GRAHAM CLULEY
H
Help Net Security
酷 壳 – CoolShell
酷 壳 – CoolShell
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
爱范儿
爱范儿
SecWiki News
SecWiki News
T
Threatpost
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Schneier on Security
Schneier on Security
T
The Exploit Database - CXSecurity.com
Google Online Security Blog
Google Online Security Blog
T
Tor Project blog
小众软件
小众软件
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Y
Y Combinator Blog
H
Hacker News: Front Page
V
V2EX
Security Latest
Security Latest
Cloudbric
Cloudbric
Simon Willison's Weblog
Simon Willison's Weblog
Attack and Defense Labs
Attack and Defense Labs
D
Darknet – Hacking Tools, Hacker News & Cyber Security
P
Proofpoint News Feed
博客园 - 三生石上(FineUI控件)
NISL@THU
NISL@THU
S
Secure Thoughts
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
V2EX - 技术
V2EX - 技术
Vercel News
Vercel News
P
Palo Alto Networks Blog
IT之家
IT之家
MyScale Blog
MyScale Blog
有赞技术团队
有赞技术团队
Application and Cybersecurity Blog
Application and Cybersecurity Blog
D
Docker
Google DeepMind News
Google DeepMind News
Webroot Blog
Webroot Blog

博客园 - 张锋

Soap 结构初识 WebCom.Net [GDI+]如何将一个彩色图像转换成黑白图像 [GDI+] 创建Images的两种方式 操作Oracle数据库实现上传图片到Blob类型的字段 如何防止同一帐户重复登录系统 世界杀毒软件排名 Scroll Page Class 解决定位问题 struct和class的区别 - 张锋 - 博客园 B/S系统中如何定位到对象 学习游戏开发经典网站 Url2Ip - 张锋 - 博客园 BLOG程序 IE功能汇总 WEB打印的相关技术分析 Blog RSS Reader 资料整理 - 张锋 Oracle常用的一些功能集锦 XML Server与XML-enabled Web Server介绍 对于想这种频繁的视图如何看待
[GDI+]如何制作出高质量的缩略图
张锋 · 2005-01-26 · via 博客园 - 张锋

如何制作出高质量的缩略图是个关键的因素,最近项目中遇到了类似需要解决的问题。
一般情况下,我们制作成的缩略图都会保存为占用空间比较小的Jpeg类型,在使用GetThumbnail方法制作成的缩略图质量感觉不理想,
如何才能保证在压缩比例最优化的情况下产生高质量的缩略图呢,经过查阅相关资料,
发现在Graphics 对象的 InterpolationMode 属性中可以产生不同质量模式的缩放图,看到这里了,不再是缩略图,而是缩放图,就是说放大的时候也可以使用。
Graphics 对象的 InterpolationMode 属性枚举定义了几种模式,列表如下:
NearestNeighbor
Bilinear
HighQualityBilinear
Bicubic
HighQualityBicubic
从名字上就可以识别NearestNeighbor 是质量最差的模式,HighQualityBicubic 是质量最好的模式了,我们借此属性看看生成的图片怎么样吧,下段代码摘自网络,大家可以把下面的函数拿去使用,这里采用了HighQualityBilinear 。

代码引用地址:http://www.bobpowell.net/highqualitythumb.htm

    Public Function GenerateThumbnail(original As Image, percentage As IntegerAs Image

     
If percentage < 1 Then

      
Throw New Exception("Thumbnail size must be aat least 1% of the original size")

     
End If

     
Dim tn As New Bitmap(CInt(original.Width * 0.01F * percentage), _

                          
CInt(original.Height * 0.01F * percentage))

     
Dim g As Graphics = Graphics.FromImage(tn)

     g.InterpolationMode 
= InterpolationMode.HighQualityBilinear 

     g.DrawImage(original, 
New Rectangle(00, tn.Width, tn.Height), _

                 
00, original.Width, original.Height, GraphicsUnit.Pixel)

     g.Dispose()

     
Return CType(tn, Image)

    
End Function