快速 TIFF 图像转换以在 Web 客户端中显示
目前,对于扫描的 TIFF 文档的预览,我使用以下方法:
Bitmap bmp = new Bitmap(@"document.tif");
var ms = new MemoryStream();
bmp.Save(ms, ImageFormat.Png);
var bmpBytes = ms.GetBuffer();
bmp.Dispose();
ms.Close();
return new FileStreamResult(new MemoryStream(bmpBytes), "image/png");
有什么方法可以加快转换速度吗?使用标准 Image.Save() 方法之外的其他方法?
我发现不安全的类在像素操作之间锁定和解锁位图数据此处,但是我不确定它是否适合我的任务(因为我只需要从一种格式转换为另一种格式)。然而我的分析器显示大约 30 毫秒获胜(116 毫秒之前,83 毫秒之后)
For preview of scanned TIFF-document currently I use the following:
Bitmap bmp = new Bitmap(@"document.tif");
var ms = new MemoryStream();
bmp.Save(ms, ImageFormat.Png);
var bmpBytes = ms.GetBuffer();
bmp.Dispose();
ms.Close();
return new FileStreamResult(new MemoryStream(bmpBytes), "image/png");
Is there any way to speed up the conversion? Using something else than standard Image.Save() method?
I've found unsafe class which locks and unlocks bitmapData between pixel manipulation here, but I'm not sure that it's suitable for my task (because I need only to transform from one format to another). However my profiler shows about 30ms win (before 116 ms, after 83 ms)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我正在使用外部工具进行转换: http://www.imagemagick.org/script/ index.php
速度快很多。
更新
执行如下操作:
I'm using an external tool for the conversion: http://www.imagemagick.org/script/index.php
It's a lot faster.
Update
Do something like this:
我想我找到了! :) Atalasoft dotImage(免费版)将图像提升至约 35 毫秒...
I think i found it! :) Atalasoft dotImage (free edition) boost image showing to about 35ms...
FreeImage 是一个很棒的图像处理库,有它的 C# 包装器。您也可以找到 FreeImage .NET 文档。
相当成熟,所以它的几个元素都得到了高度优化。
FreeImage is a great image manipulation library, there are C# wrappers for it. You can find the FreeImage .NET documentation too.
Quite mature so several elements of it are highly optimised.