windows 将位图转换为字节数组

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/354613/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 11:43:33  来源:igfitidea点击:

convert bitmap to byte array

c++windowsbitmapbytearray

提问by user37875

How can I convert a bitmap to a byte array in c++ WITHOUT the .net framework?

如何在没有 .net 框架的情况下将位图转换为 C++ 中的字节数组?

采纳答案by Konrad Rudolph

If you're using Windows, you can use GetDIBitsto retrieve the bitmap data.

如果您使用的是 Windows,则可以使用GetDIBits来检索位图数据。

回答by mackenir

If your bitmap is a device independent bitmap, you can access the pixel data using GetObject and passing in a BITMAP. This avoids making a copy of the pixel data.

如果您的位图是与设备无关的位图,您可以使用 GetObject 并传入 BITMAP 来访问像素数据。这避免了制作像素数据的副本。