Gdiplus ::位图以字节数组? [英] Gdiplus::Bitmap to BYTE array?

查看:156
本文介绍了Gdiplus ::位图以字节数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我尝试(丑陋的GDI + GDI组合...)

Here's my attempt (ugly GDI+ and GDI mix...)

// ...
BYTE               pixels[BMP_WIDTH * BMP_HEIGHT * BMP_BPP];
HBITMAP            hBitmap;
Gdiplus::Bitmap    cBitmap(BMP_WIDTH, BMP_HEIGHT, PixelFormat32bppRGB);
Gdiplus::Graphics  cGraphics(&cBitmap);
Gdiplus::Pen       cPen(Gdiplus::Color(255, 255, 0, 0));

cGraphics.DrawRectangle(&cPen, 0, 0, cBitmap.GetWidth() - 1, cBitmap.GetHeight() - 1);

// and here it get's real ugly, I'd like to change that...
cBitmap.GetHBITMAP(Gdiplus::Color(255, 255, 255), &hBitmap);
GetBitmapBits(hBitmap, sizeof(pixels), pixels);
// ...

有人告诉我使用LockBits但我真的不知道如何。我试了一下,但我失败了,所以我不打算张贴的尝试了。

Someone told me to use LockBits but I really didn't understand how. I tried it, but I failed so I'm not going to post that attempt, too.

推荐答案

您可以使用位图:: LockBits 来获取访问数据的原始数组。 这里你可以了解如何使用位图:: LockBits

You could use Bitmap::LockBits to get access to a raw array of data. Here you could read about how to use Bitmap::LockBits.

这篇关于Gdiplus ::位图以字节数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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