469,328 Members | 1,316 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,328 developers. It's quick & easy.

How to display the Bitmap that created by CreateBitmap function?

I use CBitmap::CreateBitmap create a CBitmap object, and sets the bit datas
by CBitmap::SetBitmapBits, but I can not display it on the screen(ie. use
CDC::BitBlt). Thanks in advance.

My codes like:
CBitmap bmp;
bmp.CreateBitmap(50,50,1,24,NULL); //24 bit colors
bmp.SetBitmapBits(bufLen, pBuf); //pBuf points to valid data
CDC dcMem;
dcMem.CreateCompatibleDC(pDC);
dcMem.SelectObject(&bmp);
pDC->BitBlt(0,0,50,50,&dcMem,0,0,SRCCOPY); // fault! can not display the
map.


Nov 16 '05 #1
2 13737
"Jimmy Lu" <lu*****@21cn.com> wrote in message
news:OK**************@TK2MSFTNGP10.phx.gbl...
I use CBitmap::CreateBitmap create a CBitmap object, and sets the bit datas by CBitmap::SetBitmapBits, but I can not display it on the screen(ie. use
CDC::BitBlt). Thanks in advance.

My codes like:
CBitmap bmp;
bmp.CreateBitmap(50,50,1,24,NULL); //24 bit colors
bmp.SetBitmapBits(bufLen, pBuf); //pBuf points to valid data
CDC dcMem;
dcMem.CreateCompatibleDC(pDC);
dcMem.SelectObject(&bmp);
pDC->BitBlt(0,0,50,50,&dcMem,0,0,SRCCOPY); // fault! can not display the map.


I'm pretty GDI impaired, so take this with a grain of salt. What I suspect
is that there is some disparity in the 'nBitsPixel' parameter used in your
call to CreateBitmap and the actual bits per pixel of your 'pBuf' data. How
is this buffer filled?
--
Jeff Partch [VC++ MVP]
Nov 16 '05 #2
Hi Jimmy,

You must use a compatible bitmap if you use SetBitmapBits
(CreateCompatibleBitmap). SetBitmapbits is deprecated anyway, you would be
better off working with DIB's if you want to manipulate pixels directly.

Cheers

Doug Forster

"Jimmy Lu" <lu*****@21cn.com> wrote in message
news:OK**************@TK2MSFTNGP10.phx.gbl...
I use CBitmap::CreateBitmap create a CBitmap object, and sets the bit datas by CBitmap::SetBitmapBits, but I can not display it on the screen(ie. use
CDC::BitBlt). Thanks in advance.

My codes like:
CBitmap bmp;
bmp.CreateBitmap(50,50,1,24,NULL); //24 bit colors
bmp.SetBitmapBits(bufLen, pBuf); //pBuf points to valid data
CDC dcMem;
dcMem.CreateCompatibleDC(pDC);
dcMem.SelectObject(&bmp);
pDC->BitBlt(0,0,50,50,&dcMem,0,0,SRCCOPY); // fault! can not display the map.

Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by tjonsek | last post: by
1 post views Thread by Smokey Grindel | last post: by
5 posts views Thread by =?Utf-8?B?QVRU?= | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Purva khokhar | last post: by
reply views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.