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. Create Bitmap From buffer

Create Bitmap From buffer

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsannouncement
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.
  • M Offline
    M Offline
    Md Mazharul Islam Khan
    wrote on last edited by
    #1

    I got pbuffer from a camera device. Now i have to make bitmap and show in thumnail view. LPBYTE pBuffer=new BYTE[height*width*3]; memcpy(pBuffer,(LPBYTE)lParam,height*width*3); what i did: DrawThumbnails(){ CBitmap* pImage = NULL; HBITMAP hBitmap = NULL; HDC hMemDC = NULL; HGDIOBJ hOldObj = NULL; POINT pt; int x, i; // = m_ImageListThumb.GetImageCount(); CString str; str.Format("%d",pBuffer); AfxMessageBox(str); // no images // set the length of the space between thumbnails // you can also calculate and set it based on the length of your list control int nGap = 6; // hold the window update to avoid flicking m_ListThumbnail.SetRedraw(FALSE); // reset our image list // for( i=0; im_hWnd; // create thumbnail bitmap section bih.biWidth = THUMBNAIL_WIDTH; bih.biHeight = THUMBNAIL_HEIGHT; // hBitmap = CreateBitmapIndirect(&bitmap); hBitmap = ::CreateDIBSection(NULL,&bmi, DIB_RGB_COLORS, NULL, NULL, 0); //hBitmap = ::CreateDIBitmap(hDC,&bih,CBM_INIT,pBuffer,(BITMAPINFO*)&bih,DIB_RGB_COLORS); //hBitmap = CreateBitmap(m_nWidth,m_nHeight,1,24,) // restore dib header //dib.m_pBMI->bmiHeader.biWidth = nWidth; //dib.m_pBMI->bmiHeader.biHeight = nHeight; bih.biWidth= m_nWidth; bih.biHeight = m_nHeight; // select thumbnail bitmap into screen dc

    C 1 Reply Last reply
    0
    • M Md Mazharul Islam Khan

      I got pbuffer from a camera device. Now i have to make bitmap and show in thumnail view. LPBYTE pBuffer=new BYTE[height*width*3]; memcpy(pBuffer,(LPBYTE)lParam,height*width*3); what i did: DrawThumbnails(){ CBitmap* pImage = NULL; HBITMAP hBitmap = NULL; HDC hMemDC = NULL; HGDIOBJ hOldObj = NULL; POINT pt; int x, i; // = m_ImageListThumb.GetImageCount(); CString str; str.Format("%d",pBuffer); AfxMessageBox(str); // no images // set the length of the space between thumbnails // you can also calculate and set it based on the length of your list control int nGap = 6; // hold the window update to avoid flicking m_ListThumbnail.SetRedraw(FALSE); // reset our image list // for( i=0; im_hWnd; // create thumbnail bitmap section bih.biWidth = THUMBNAIL_WIDTH; bih.biHeight = THUMBNAIL_HEIGHT; // hBitmap = CreateBitmapIndirect(&bitmap); hBitmap = ::CreateDIBSection(NULL,&bmi, DIB_RGB_COLORS, NULL, NULL, 0); //hBitmap = ::CreateDIBitmap(hDC,&bih,CBM_INIT,pBuffer,(BITMAPINFO*)&bih,DIB_RGB_COLORS); //hBitmap = CreateBitmap(m_nWidth,m_nHeight,1,24,) // restore dib header //dib.m_pBMI->bmiHeader.biWidth = nWidth; //dib.m_pBMI->bmiHeader.biHeight = nHeight; bih.biWidth= m_nWidth; bih.biHeight = m_nHeight; // select thumbnail bitmap into screen dc

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      you don't say what the error is, or what results you're getting. but, i see one big problem: CreateDIBitmap and CreateDIBSection require that the pixels are arranged the way they are arranged in a DIB: 1. rows are ordered bottom-up 2. rows are padded to multiples of 4 bytes each 3. RGB pixels are in BGR color order your buffer of w * h * 3 pixels is almost certainly not accounting for requirement 2.

      image processing toolkits | batch image processing | blogging

      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