473,554 Members | 2,949 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to display the Bitmap that created by CreateBitmap function?

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

My codes like:
CBitmap bmp;
bmp.CreateBitma p(50,50,1,24,NU LL); //24 bit colors
bmp.SetBitmapBi ts(bufLen, pBuf); //pBuf points to valid data
CDC dcMem;
dcMem.CreateCom patibleDC(pDC);
dcMem.SelectObj ect(&bmp);
pDC->BitBlt(0,0,50, 50,&dcMem,0,0,S RCCOPY); // fault! can not display the
map.


Nov 16 '05 #1
2 14034
"Jimmy Lu" <lu*****@21cn.c om> wrote in message
news:OK******** ******@TK2MSFTN GP10.phx.gbl...
I use CBitmap::Create Bitmap create a CBitmap object, and sets the bit datas by CBitmap::SetBit mapBits, but I can not display it on the screen(ie. use
CDC::BitBlt). Thanks in advance.

My codes like:
CBitmap bmp;
bmp.CreateBitma p(50,50,1,24,NU LL); //24 bit colors
bmp.SetBitmapBi ts(bufLen, pBuf); //pBuf points to valid data
CDC dcMem;
dcMem.CreateCom patibleDC(pDC);
dcMem.SelectObj ect(&bmp);
pDC->BitBlt(0,0,50, 50,&dcMem,0,0,S RCCOPY); // 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
(CreateCompatib leBitmap). 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.c om> wrote in message
news:OK******** ******@TK2MSFTN GP10.phx.gbl...
I use CBitmap::Create Bitmap create a CBitmap object, and sets the bit datas by CBitmap::SetBit mapBits, but I can not display it on the screen(ie. use
CDC::BitBlt). Thanks in advance.

My codes like:
CBitmap bmp;
bmp.CreateBitma p(50,50,1,24,NU LL); //24 bit colors
bmp.SetBitmapBi ts(bufLen, pBuf); //pBuf points to valid data
CDC dcMem;
dcMem.CreateCom patibleDC(pDC);
dcMem.SelectObj ect(&bmp);
pDC->BitBlt(0,0,50, 50,&dcMem,0,0,S RCCOPY); // 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
2435
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 in the DataGrid-Cell's, but a black background... Does anybody has any idea what I am doing wrong? Thanks a lot in advance,
2
2631
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 bitmap created by right clicking on the project, selecting add new item, then add bitmap file). The project explorer says my bitmap is called...
2
6683
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 don't get an exception but it appears the Bitmap is blank. Can anyone share some knowledge on this?
12
1993
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 = System.Drawing.Image.FromFile(Me.File1.Value) Dim thisFormat = g.RawFormat Dim imgOutput As New Bitmap(g, 800, 600) Dim strFileType As String Dim strFileName As String...
0
7401
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 time into a Crystal Report. The path to the file is stored in a varchar(100) field in a table in SQL Server. The Crystal Report displays the...
1
7813
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 compression ratio is.. thanks!
12
3341
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 draw it into a Bitmap. Is there a graphics method that can help?
0
1189
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 System::Drawing::Bitmap from them? Im using mixed-mode in C++/CLI
5
2562
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, I want to add a button. When user click on it, I want the bitmap shift to the left by 10% and fill the new area with new information requested....
0
7780
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8010
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7530
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7862
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6119
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5414
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
1994
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1111
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
812
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.