我想编写一个应用程序,将图像(jpeg,png,tiff,gif,...)作为流并将其转换为具有无损压缩的 jrx(jpeg xr)。
这就是我迄今为止尝试过的,没有可用的结果:
using System.Windows.Media.Imaging;
//decode jpg
public static BitmapSource ReadJpeg(Stream imageStreamSource)
{
JpegBitmapDecoder decoder = new JpegBitmapDecoder(imageStreamSource, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
BitmapSource bitmapSource = decoder.Frames[0];
return bitmapSource;
}
//encode
public static Stream Encode(BitmapSource image)
{
WmpBitmapEncoder encoder = new WmpBitmapEncoder();
MemoryStream s = new MemoryStream();
encoder.Frames.Add(BitmapFrame.Create(image));
encoder.Save(s);
return s;
}
有人可以指出我正确的方向吗?我现在在这里挂了一段时间。
如果您需要更多信息,请询问。
System.Drawing.Bitmap to JPEG XR适用于给定的输入格式,但没有完全涵盖我的问题,因为缺少解码图像的部分。
谢谢大家为我指明正确的方向!我现在知道了,如何进行。