将二进制文件转换为图像 [英] Convert Binary File To image

查看:477
本文介绍了将二进制文件转换为图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将二进制数据转换为文件并执行文件时,我看到图形文件的此错误

Windows照片查看器无法打开此图片,因为该文件似乎已损坏或损坏




这是我的方法File.WriteAllBytes(path,fileContent);

when i convert binary data to file and execute the file i see this error for graphic file
Windows Photo Viewer can't open this picture because the file appears to be damaged or corrupted


this is my method File.WriteAllBytes(path, fileContent);

推荐答案

从未尝试过这种方式...

我认为序列化方法(ObjectToByteArray)创建的内存转储以不同于Bitmap.Save(流,格式)的格式返回字节。

因此我建议您通过恢复序列化方法的步骤来反序列化图像,然后使用Bitmap.Save(文件名,格式)将图像写入磁盘。
Never tried it this way...
I think that the "memory dump" created by your serialization method (ObjectToByteArray) returns the bytes in a different format than Bitmap.Save(stream, format).
Hence I'd suggest you de-serialize the image by reverting the the steps of your serialization method, and then write the image to disk with Bitmap.Save(filename, format).


这篇关于将二进制文件转换为图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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