16bpp图像原始文件怎么解析或转化

jianzhinengwan jianzhinengwan 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
原始文件.dat,每个像素16bit(应该是gray16),300X300,下面的代码没用

string path = "C:\\test.dat";
byte[] byteArray = null;
if (File.Exists(path))
{
byteArray = File.ReadAllBytes(path);
}
BitmapImage item = new BitmapImage();
MemoryStream ms = new MemoryStream(byteArray);


item.BeginInit();
item.StreamSource = ms;
item.CacheOption = BitmapCacheOption.OnLoad;
item.CreateOptions = BitmapCreateOptions.None;
//item.EndInit();
item.Freeze();
ms.Dispose();


JpegBitmapEncoder en = new JpegBitmapEncoder();
en.Frames.Add(BitmapFrame.Create(item));
FileStream fstream = new FileStream("C:\\Users\\Sai\\Desktop\\sj.jpg",
FileMode.Create, FileAccess.ReadWrite);
en.Save(fstream);
fstream.Close();
...全文

相关推荐

评论 1
收藏 已收藏
分享
返回顶部
jianzhinengwan
C# 111,129 成员 642,538 内容