[英]How to convert TIFF to JPEG?
I am trying to convert a TIFF file to JPEG using FreeImage. 我想使用FreeImage将TIFF文件转换为JPEG。
The problem is that FreeIamge.SaveToStream
doesn't actually do anything. 问题是FreeIamge.SaveToStream
实际上没有做任何事情。 Even after the call, stream
has a Length
, Capacity
and Position
of 0. 即使在呼叫之后, stream
的Length
, Capacity
和Position
为0。
This is my code: 这是我的代码:
using (var stream = new MemoryStream())
{
var image = FreeImage.LoadEx(fileName);
FreeImage.SaveToStream(image, stream, FREE_IMAGE_FORMAT.FIF_JPEG,
FREE_IMAGE_SAVE_FLAGS.JPEG_QUALITYSUPERB);
// stream.Length, stream.Capacity & stream.Position are all 0 here
}
What am I doing wrong? 我究竟做错了什么?
The problem was the input - a 16 bit image created by another image library. 问题是输入 - 由另一个图像库创建的16位图像。 It looks like FreeImage has some problems with 16 bit images as GDI+ could read it without problems. 看起来FreeImage在16位图像方面存在一些问题,因为GDI +可以毫无问题地读取它。 I switched the input to a 24 bit image and the code in my question started working. 我将输入切换为24位图像,我的问题中的代码开始工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.