Compatible bitmap in compatible DC 
Author Message
 Compatible bitmap in compatible DC

Hello,

I would like to prepare a compatible bitmap (without loading a ressource
bitmap) in a compatible DC. But only if I use LoadBitmap( ) I can draw the
lines. Otherwise I see a white blank screen instead of blue lines.What did I
do wrong?

Thank you for your help.

Frank

void CTestDruckScrollView::OnDraw(CDC* pDC)
{
   INT         iLoop;

   CPen         pen1;
   CPen         *ppenOld;
   CDC          dcMem;
   CBitmap      bmp1;
   CBitmap      *pbmpOld;

   dcMem.CreateCompatibleDC ( pDC );

   pen1.CreatePen ( PS_SOLID, 5, RGB ( 0,0,255) );
   bmp1.CreateCompatibleBitmap ( pDC, 2000, 2000 );

/*************************************************/
//   bmp1.LoadBitmap ( IDB_TEST );     // just if i activate this line it
works
/*************************************************/
   ppenOld = dcMem.SelectObject ( &pen1 );
   pbmpOld = dcMem.SelectObject ( &bmp1 );

   // lines
   for ( iLoop = 0; iLoop < 1000; iLoop += 10 ) {
      dcMem.MoveTo ( 0, iLoop );
      dcMem.LineTo ( 2000, iLoop );
   }

   pDC->BitBlt ( 0, 0, 2000, 2000, &dcMem, 0, 0, SRCCOPY );

   dcMem.SelectObject ( ppenOld );
   dcMem.SelectObject ( pbmpOld );

   pen1.DeleteObject ( );
   bmp1.DeleteObject ( );

   dcMem.DeleteDC ( );

Quote:
}



Sun, 14 Nov 2004 15:56:07 GMT  
 Compatible bitmap in compatible DC
Hi Frank,

I created a larger bitmap in memory, and I found I a last error of 0x8 (not
enough storage). Checking the MSDN, I found the information below:

"Windows 95/98/Me: The created bitmap cannot exceed 16MB in size."

I use Win2k to test the problem, and it also has some limitations.
Therefore, you need to create several smaller bitmaps instead of a large
one.

I hope this helps.

Best Regards,
Leo Chen

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------

| Newsgroups: microsoft.public.vc.mfc
| Subject: Compatible bitmap in compatible DC
| Date: Wed, 29 May 2002 09:56:07 +0200
| Organization: IABG Industrieanlagen-Betriebsgesellschaft mbH, Germany

| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 5.50.4522.1200
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
| Lines: 59
| NNTP-Posting-Host: iabgfw.iabg.de
| X-Trace: 1022659224 read.news.de.uu.net 182 194.139.245.2

| Path:
cpmsftngxa07!INTERNETBUILD41!cppssbbsa01.microsoft.com!news-out.cwix.com!new
sfeed.cwix.com!torn!sunqbc.risq.qc.ca!newsfeed.online.be!bnewspeer00.bru.ops
eu.uu.net!bnewspost00.bru.ops.eu.uu.net!emea.uu.net!read.news.de.uu.net!not
-for-mail
| Xref: cpmsftngxa07 microsoft.public.vc.mfc:328233
| X-Tomcat-NG: microsoft.public.vc.mfc
|
| Hello,
|
| I would like to prepare a compatible bitmap (without loading a ressource
| bitmap) in a compatible DC. But only if I use LoadBitmap( ) I can draw the
| lines. Otherwise I see a white blank screen instead of blue lines.What
did I
| do wrong?
|
| Thank you for your help.
|
| Frank
|
|
|
|
|
|
|
|
| void CTestDruckScrollView::OnDraw(CDC* pDC)
| {
|    INT         iLoop;
|
|    CPen         pen1;
|    CPen         *ppenOld;
|    CDC          dcMem;
|    CBitmap      bmp1;
|    CBitmap      *pbmpOld;
|
|    dcMem.CreateCompatibleDC ( pDC );
|
|    pen1.CreatePen ( PS_SOLID, 5, RGB ( 0,0,255) );
|    bmp1.CreateCompatibleBitmap ( pDC, 2000, 2000 );
|
| /*************************************************/
| //   bmp1.LoadBitmap ( IDB_TEST );     // just if i activate this line it
| works
| /*************************************************/
|    ppenOld = dcMem.SelectObject ( &pen1 );
|    pbmpOld = dcMem.SelectObject ( &bmp1 );
|
|    // lines
|    for ( iLoop = 0; iLoop < 1000; iLoop += 10 ) {
|       dcMem.MoveTo ( 0, iLoop );
|       dcMem.LineTo ( 2000, iLoop );
|    }
|
|    pDC->BitBlt ( 0, 0, 2000, 2000, &dcMem, 0, 0, SRCCOPY );
|
|    dcMem.SelectObject ( ppenOld );
|    dcMem.SelectObject ( pbmpOld );
|
|    pen1.DeleteObject ( );
|    bmp1.DeleteObject ( );
|
|    dcMem.DeleteDC ( );
| }
|
|
|
|



Tue, 16 Nov 2004 09:41:37 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Problem: Compatible bitmap for screen DC

2. creating compatible dc

3. Changing resolution of compatible DC

4. Compatible DC in a dialog box

5. Compatible DC's and Bitmaps are not quite compatible!

6. fatest way to access a Compatible Bitmap?

7. unable to render a compatible bitmap?

8. Visual C++.net STANDARD compatible HOME EDITION XP

9. Creating Visual C++ 6.0 compatible pdb files

10. are MFC and Managed C++ compatible ?

11. char * to some known .NET compatible datatype

12. VC++ 7.0 compatible and speed !

 

 
Powered by phpBB® Forum Software