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. How to use GetBitmapBits( ) correctly

How to use GetBitmapBits( ) correctly

Scheduled Pinned Locked Moved C / C++ / MFC
c++graphicstutoriallearning
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.
  • C Offline
    C Offline
    Chen XuNuo
    wrote on last edited by
    #1

    I want to save a 24 bit bitmap's RGB data as a file.I firstly import it to resource editor. void CReadView::OnDraw(CDC* pDC) { CReadDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here int i,j; int counter=0; BYTE data[640*480*3]; CBitmap bmp; bmp.LoadBitmap(IDB_BITMAP1); bmp.GetBitmapBits(640*480*3,data); BITMAP bitmap; bmp.GetBitmap(&bitmap); for(i=0;i<bitmap.bmHeight;i++) for(j=0;j<bitmap.bmWidth;j++) { pDC->SetPixel(j,i, RGB(data[counter],data[counter+1],data[counter+2])); counter+=3; } } The result is not correct.:confused:

    A 1 Reply Last reply
    0
    • C Chen XuNuo

      I want to save a 24 bit bitmap's RGB data as a file.I firstly import it to resource editor. void CReadView::OnDraw(CDC* pDC) { CReadDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here int i,j; int counter=0; BYTE data[640*480*3]; CBitmap bmp; bmp.LoadBitmap(IDB_BITMAP1); bmp.GetBitmapBits(640*480*3,data); BITMAP bitmap; bmp.GetBitmap(&bitmap); for(i=0;i<bitmap.bmHeight;i++) for(j=0;j<bitmap.bmWidth;j++) { pDC->SetPixel(j,i, RGB(data[counter],data[counter+1],data[counter+2])); counter+=3; } } The result is not correct.:confused:

      A Offline
      A Offline
      Anthony Appleyard
      wrote on last edited by
      #2

      See [^]

      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