473,387 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 14019
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: DraguVaso | last post by:
Hi, In the override of the Paint-method of a DataGridTextBoxColumn I want to show an image with BitBlt, to see what I can gain there on performance. The problem is: It doesn't show me the image...
2
by: Michael Murphy | last post by:
At the risk of being publically humiliated, might I ask the following simple question. I have a solution with one project. This project, WindowsApplication1, has one "form" and one "bitmap" (the...
2
by: active | last post by:
I find Bitmap.Save works for WMF files but Bitmap.FromFile does not. If I use FromFile on a WMF file that came with VS I get an exception. If I use it on a WMF file created with Bitmap.Save I...
12
by: tjonsek | last post by:
I get a generic error (not very helpful) when attempting to save a re-sized image back to its original location. Here is the code snippet: Dim g As System.Drawing.Image =...
0
by: Jeff | last post by:
Help!!! The bitmap I am trying to display in a sample Crystal Report is coming up with much less quality than the original bitmap. I have a 300x300 dpi bitmap file that I want to insert at run...
1
by: Smokey Grindel | last post by:
I have a bitmap object I want to return as a JPEG image with a compression set at 90% and progressive passes enabled, how can I do this in .NET 2.0? Progressive passes are not necessary but the...
12
by: active | last post by:
I've been looking on the Internet for a way to convert a DIB to a Bitmap without success. Now I'm wondering if that is the approach I should be taking. All I want to do is display the DIB or...
0
by: gudguy | last post by:
dear gurus, void CreateBitmap() { BITMAPINFO bitmapInfo; int nBufSize; BYTE *pbBitmap; // assuming I have initialized all the variables above, how can I create a...
5
by: =?Utf-8?B?QVRU?= | last post by:
I have a bitmap of 100X100. On the load, the bitmap is created by a function (createimage()). On my OnPaint, I draw the image back to the screen (e.Graphics.DrawImage( bitmap, destrect)). Now,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.