472,146 Members | 1,245 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,146 software developers and data experts.

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 13884
"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 Saiars | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.