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

推荐订阅源

博客园_首页
阮一峰的网络日志
阮一峰的网络日志
S
Secure Thoughts
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Threat Research - Cisco Blogs
P
Privacy & Cybersecurity Law Blog
The Hacker News
The Hacker News
H
Heimdal Security Blog
W
WeLiveSecurity
L
LINUX DO - 热门话题
Hacker News: Ask HN
Hacker News: Ask HN
WordPress大学
WordPress大学
The Last Watchdog
The Last Watchdog
Hugging Face - Blog
Hugging Face - Blog
博客园 - 【当耐特】
D
DataBreaches.Net
I
Intezer
Webroot Blog
Webroot Blog
C
Cisco Blogs
AWS News Blog
AWS News Blog
博客园 - 聂微东
T
The Blog of Author Tim Ferriss
V
Vulnerabilities – Threatpost
罗磊的独立博客
Google DeepMind News
Google DeepMind News
N
Netflix TechBlog - Medium
Schneier on Security
Schneier on Security
宝玉的分享
宝玉的分享
博客园 - 叶小钗
PCI Perspectives
PCI Perspectives
D
Docker
Scott Helme
Scott Helme
NISL@THU
NISL@THU
J
Java Code Geeks
B
Blog RSS Feed
Google Online Security Blog
Google Online Security Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
The Exploit Database - CXSecurity.com
AI
AI
美团技术团队
Cloudbric
Cloudbric
月光博客
月光博客
P
Proofpoint News Feed
T
Tailwind CSS Blog
Google DeepMind News
Google DeepMind News
小众软件
小众软件
www.infosecurity-magazine.com
www.infosecurity-magazine.com
The Cloudflare Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org

博客园 - 张锋

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