473,545 Members | 2,451 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 14033
"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
2434
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
2630
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
6682
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
7399
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
7812
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
3340
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
1188
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
2561
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
7487
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7680
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. ...
1
7446
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
7778
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
4966
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3476
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3459
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1908
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
0
731
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.