无法使用Image.FromStream或Bitmap.FromFile打开Color Tiff [英] Unable to Open Color Tiff using Image.FromStream or Bitmap.FromFile

查看:97
本文介绍了无法使用Image.FromStream或Bitmap.FromFile打开Color Tiff的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在打开颜色.tiff时遇到了麻烦。


在.tiff上调用Image.FromStream会抛出一个无效参数。错误。


在.tiff上调用Bitmap.FromFile会抛出一个System.OutOfMemory。错误(文件大小为647k)。


.tiff本身没有损坏,我可以使用MS Picture Manager或MS Document Imaging打开它(虽然当我用Windows Picture打开它时和传真查看器我收到预览不可用消息。


* .tiff来自扫描文档;当我用黑色和黑色扫描文档时白色.tiff打开很好,这肯定与它的颜色有关。


我在网页上使用Atalasoft控件上传图像。我可以从.tiff创建一个ImageInfo对象,从中可以看出.tiff是Image Type Tiff,Pixel24bppBgr,300 dpi。


如果有人有源代码,他们会用来成功打开颜色.tiff我非常感谢看到它。

解决方案

System.OutOfMemory是一个糟糕的错误。这就是因为错误的原因而被抛出大量时间的东西。如果你试图打开一个文件(来自你的应用程序)仍在编写(通过扫描应用程序),例如,你会得到内存不足


位图.FromFile应该避免。 MS表示它不是一个错误,但只要您使用图片,该呼叫将保持打开到HDD上文件的链接 - 然后再延长一段时间。基本上只要你的应用程序仍然打开O.S.认为它与文件有关。


这和我一样有帮助......其他人?


我可以'使用Image.FromStream,Bitmap.FromStream或Bitmap.FromFile打开任何颜色tiff。


这是一个控制台应用程序,它贬低了我的意思。使用所有3种方法,黑色和白色tiff打开正常。所有3种方法的颜色tiff都失败了。


我在这个论坛上看不到附加tif文件的方法,但我想任何颜色都会产生错误。

展开 | 选择 | Wrap | 行号


TIFF有一些选项,如LZW压缩以及一个文件中的多个图像。你可能碰到其中一个问题。


你应该从一个已知条件的TIFF开始:一个图像,没有LZW压缩。然后测试一个图像的tiff,是压缩。等等。尝试各种排列以确切了解导致失败的原因。

网上有几个TIFF classess。


打开其他源代码是学习技巧的好方法。

这个TIFF查看器的项目可能是一个值得学习的好方法。 br /> http://www.codeproject.com/KB/cs /mul...iffviewer.aspx

I''m having trouble opening a color .tiff.

Calling Image.FromStream on the .tiff throws an "invalid parameter" error.

Calling Bitmap.FromFile on the .tiff throws a "System.OutOfMemory" error (the file size is 647k).

The .tiff itself is not corrupt, I can open it using MS Picture Manager or MS Document Imaging (although when I open it using Windows Picture and Fax Viewer I get a "preview not available" message).

The *.tiff comes from a scanned document; when I scan the document in black & white the .tiff opens fine, this certainly has to do with it being in color.

I am using Atalasoft controls on the web page where the image is uploaded. I can create an ImageInfo object from the .tiff and can see from it that the .tiff is Image Type Tiff, Pixel24bppBgr, 300 dpi.

If anyone has source code they use to succesfully open a color .tiff I would very much appreciate seeing it.

解决方案

System.OutOfMemory is a crappy error. That is what gets thrown a lot of time for the wrong reason. If you try to open a file (from your application) that is still being written (by the scanning application) for example, you''ll get "out of memory"

Bitmap.FromFile should be avoided. MS says its not a bug, but that call will keep a an open link to the file on HDD for as long as you are using the picture - and then a while longer. Basically for as long as your application is still open the O.S. thinks it is linked to the file.

That''s as much help as I have... Anyone else?


I can''t open any color tiff using Image.FromStream, Bitmap.FromStream or Bitmap.FromFile.

Here is a console app that demonsrates what I mean. The black and white tiff opens fine using all 3 methods. The color tiff fails on all 3 methods.

I see no way on this forum to attach the tif files, but I imagine any color tif would generate the error.

Expand|Select|Wrap|Line Numbers


TIFF has a few options such as LZW compression as well as multiple images within one file. You are probably bumping up against one of those issues.

You should start with a TIFF of a known condition: One image, no LZW compression. Then test with a tiff of one image, yes compression. And so on. Try the various permutation to see exactly what is causing the failure.

There are several TIFF classess available on the net.

Opening up other source code is a great way to learn techniques.
This project for a TIFF viewer would probably be a terrific source to learn from.
http://www.codeproject.com/KB/cs/mul...iffviewer.aspx


这篇关于无法使用Image.FromStream或Bitmap.FromFile打开Color Tiff的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆