Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. MFC - CBitmap BitBlt

MFC - CBitmap BitBlt

Scheduled Pinned Locked Moved C / C++ / MFC
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rajesh Rajan Pankapattu
    wrote on last edited by
    #1

    The below given function displays nothing. Why...? How could I correct the problem..? void CImageProcessorView::OnDraw(CDC *theDC) { CBitmap Bitmap; Bitmap.CreateBitmap(100,100,1,24,NULL); BITMAP bm; Bitmap.GetObject(sizeof(BITMAP),&bm); BYTE * pData=(BYTE *)new BYTE[bm.bmHeight *bm.bmWidthBytes ]; // the 24 bit bitmap buffer for (int y=0;y < bm.bmHeight;y++){ for(int x=0;x < bm.bmWidth;x++){ pData[x*3+0+y*bm.bmWidthBytes]=0; pData[x*3+1+y*bm.bmWidthBytes]=0; pData[x*3+2+y*bm.bmWidthBytes]=255; // fill red in buffer } } Bitmap.SetBitmapBits(bm.bmHeight *bm.bmWidthBytes ,pData); CDC MemDC; MemDC.CreateCompatibleDC(theDC); CBitmap *pOldBitmap=MemDC.SelectObject(&Bitmap); theDC->BitBlt(0,0,bm.bmWidth,bm.bmHeight,&MemDC,0,0,SRCCOPY); MemDC.SelectObject(pOldBitmap); delete [] pData; } Rajesh Rajan Pankapattu

    L 1 Reply Last reply
    0
    • R Rajesh Rajan Pankapattu

      The below given function displays nothing. Why...? How could I correct the problem..? void CImageProcessorView::OnDraw(CDC *theDC) { CBitmap Bitmap; Bitmap.CreateBitmap(100,100,1,24,NULL); BITMAP bm; Bitmap.GetObject(sizeof(BITMAP),&bm); BYTE * pData=(BYTE *)new BYTE[bm.bmHeight *bm.bmWidthBytes ]; // the 24 bit bitmap buffer for (int y=0;y < bm.bmHeight;y++){ for(int x=0;x < bm.bmWidth;x++){ pData[x*3+0+y*bm.bmWidthBytes]=0; pData[x*3+1+y*bm.bmWidthBytes]=0; pData[x*3+2+y*bm.bmWidthBytes]=255; // fill red in buffer } } Bitmap.SetBitmapBits(bm.bmHeight *bm.bmWidthBytes ,pData); CDC MemDC; MemDC.CreateCompatibleDC(theDC); CBitmap *pOldBitmap=MemDC.SelectObject(&Bitmap); theDC->BitBlt(0,0,bm.bmWidth,bm.bmHeight,&MemDC,0,0,SRCCOPY); MemDC.SelectObject(pOldBitmap); delete [] pData; } Rajesh Rajan Pankapattu

      L Offline
      L Offline
      lafleon
      wrote on last edited by
      #2

      Hello, Your bitmaps are incompatible. Just try Bitmap.CreateCompatibleBitmap(theDC, 100, 100); instead of Bitmap.CreateBitmap(100,100,1,24,NULL); Regards,

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups