简体   繁体   中英

Creating a bitmap from char* buffer MFC

I'm working with an unsigned char *buffer that contains an image (16bit grayscale). I'm attempting to load this buffer into a HBITMAP so that I can use SetBitmap on a picture box control to show a live stream of images in memory.

I've tried this so far:

HBITMAP memBMP;
memBMP = CreateBitmap(1080,1280,1,16,pBuf);
mPictureBox1.SetBitmap(memBMP);

Unfortunately the dialog box goes blank for a brief moment and then displays the buttons and elements again after iterating through all the images in memeory. Any suggestions would be much appreciated; I tried exhausting my google resources, but I couldn't find a clearcut example of how to do this.

Thanks!

You can learn everything you need to know about CreateDIBSection from this MFC sample app. But you will have to compress your 16-bit data to 8-bit grayscale.

http://www.codeproject.com/Articles/31/A-DIBSection-wrapper-for-Win32-and-WinCE

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM