将 Bmp 灰度读入 C
我寻找如何在 C 下将 Bmp 文件读入二维或一维数组,有很多解决方案,但不是我需要的。 我需要将黑白 bmp 读入(开始)二维数组,该数组必须包含从 0 到 255(灰度)的值 然后将其转换为一维数组(但这不是问题)。 Matlab 自动执行此操作,但我希望在 C/C++ 下更加自主地工作 最后 bmp 应保存到 Postgre 数据库 int 数组中。 谢谢
I looked for how to read a Bmp file into a 2 or 1 dimensional Array under C , there are many solutions but not the one i need.
I need to read the Black and white bmp into (to beginn) 2 dimensional array which have to contain values from 0 to 255 (greyscale)
and then transform it to 1 dimensional array(but that's not a problem).
Matlab does this automticly but i want to be more autonomous working under C/C++
at the end the bmp shall be saved into a Postgre Database int array.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我为另一个 SO 问题制作了一个 bmp 加载器:
http://nishi.dreamhosters.com/u/so_bmp_v0.zip
示例 bmp 是 RGB 的,但它似乎也适用于灰度。
位图这里是指向像素表的指针(应设为无符号
但为了正确访问)。请注意,bmp 中的像素行可以存储在
相反的顺序。
There's a bmp loader which I made for another SO question:
http://nishi.dreamhosters.com/u/so_bmp_v0.zip
The example bmp there is RGB, but it seems to work with grayscale as well.
bitmap here is the pointer to the pixel table (should be made unsigned
for proper access though). Note that pixel rows in bmp can be stored in
reverse order.
抱歉,看错问题了:/
如果你不介意稍微“扭曲”规则Sorry, misread question :/
If you don't mind "twisting" the rules a tiny little bit