如何访问每个字节中的位图图像 [英] How to access each byte in a bitmap image

查看:131
本文介绍了如何访问每个字节中的位图图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我有一个位图图像,是可以遍历图像中的所有单个字节?如果是的话,怎么办?

Say I have a bitmap image, is it possible to iterate through all the individual bytes in the image? If yes, how?

推荐答案

我发现这一点:的 http://channel9.msdn.com/forums/TechOff/108813-Bitmap-to-byte-array/

说,你可以使用一个MemoryStream和.Save方法,它看起来会是这样的:

Saying that you could use a Memorystream and the .Save method it'd look like this:

System.Drawing.Bitmap bmp = GetTheBitmap();
System.IO.MemoryStream stream = new System.IO.MemoryStream();
bmp.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp);
stream.Position = 0;
byte[] data = new byte[stream.Length];
stream.Read(data, 0, stream.Length);

这篇关于如何访问每个字节中的位图图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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