参数无效时节省TIFF流 [英] Parameter is not valid when saving TIFF to stream
问题描述
我有一个多页TIFF说我分手了逐页使用LEADTOOLS,并改变对他们的COM pression是与第三方兼容。当我尝试将图像保存到一个MemoryStream,我得到一个参数无效例外。然而,这种的只有的情况发生在其计算机上,或我的测试机运行Server 2008。我不能在我的开发机器上重现此(使用VS2008的Win 7)。这里是code:
I have a multi-page TIFF that I'm splitting up page by page using Leadtools, and changing the compression on them to be compatible with a third party. When I try to save the image to a memoryStream, I get a Parameter is not valid exception. However, this only happens on their machine, or my test machine running Server 2008. I cannot reproduce this on my development machine (Win 7 using VS2008). Here is the code:
RasterImage image = codecs.Load( file, 0, CodecsLoadByteOrder.RgbOrGray, currentPage, currentPage + (detail.Pages - 1) );
Image newImage = RasterImageConverter.ConvertToImage( image, ConvertToImageOptions.None );
MemoryStream memStream = new MemoryStream();
ImageCodecInfo encoderInfo = GetEncoderInfo( );
EncoderParameters encoderParams = new EncoderParameters( 1 );
EncoderParameter parameter = new EncoderParameter( System.Drawing.Imaging.Encoder.Compression, (long)EncoderValue.CompressionCCITT4 );
encoderParams.Param[0] = parameter;
newImage.Save(memStream, encoderInfo , encoderParams);
在这个有什么想法?感谢您的帮助!
Any thoughts on this? Thanks for the help!
推荐答案
检查图像的像素格式。如果什么事比1位等,这将失败 - 你不能对任何事情比1位其他使用CCITT。它也可能是因为特定的OS不具有CCITT4子codec且可能仅具有一个CCITT3(虽然这是非常不可能的)。
Check the pixel format of the image. If it's anything other than 1 bit, this will fail - you can't use CCITT on anything other than 1 bit. It could also be that the particular OS doesn't have a CCITT4 subcodec and might only have a CCITT3 (although this is highly unlikely).
这篇关于参数无效时节省TIFF流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!