title: Display 32bit bitmap - Palette
body: <p>I have an image data in a buffer(type - long) from a scanner which is 32 bit. </p>
  
  <p>For example, buffer[0]'s corresponding pixel value is 952 which is [184, 3, 0, 0] &lt;-[R,G,B,A];</p>
  
  <p>I want to display/Paint/draw on to the screen; I am confused when i tried to read about displying bitmaps. I looked at win32 functions, CBitmap class, windows forms (picture box) etc I am hard to understand the general idea/appraoch for displaying this buffer data on to a application window.</p>
  
  <p>I have constructed the BITMAPFILEHEADER AND BITMAPINFOHEADER; Has the pixel data in a buffer, (unsigned char *)vInBuff whose size is vImageSz;</p>
  
  <pre><code>//construct the BMP file Header
  vBmfh.bfType      = 19778;
  vBmfh.bfSize      = 54+vImageSz;//size of the whole image
  vBmfh.bfReserved2 = 0;
  vBmfh.bfReserved1 = 0;
  vBmfh.bfOffBits   = 54;//offset from where the pixel data can be found
  //Construct the BMP info header
  vBmih.biSize        = 40;//size of header from this point
  vBmih.biWidth       = 1004;
  vBmih.biHeight      = 1002;
  vBmih.biPlanes      = 1;
  vBmih.biCompression = BI_RGB;
  vBmih.biSizeImage   = vBmih.biWidth*vBmih.biHeight*4;
  vBmih.biBitCount    = 32;
  vBmih.biClrUsed     = 0;
  vBmih.biClrUsed     = 0;
  </code></pre>
  
  <p>1.What is that i should be doing next to display this?</p>
  
  <p>2 What should i be using to display the 32bit bitmap? I see people using createwindows functions, windows forms, MFC etc;  </p>
  
  <p>3.I also understand that BitBlt,createDIBSection, OnPaint etc are being used? I am confused by these various functions and coding platforms? Please suggest me a simple approach.</p>
  
  <p>4.How can i create a palette to display a 32 bit image?</p>
  
  <p>Thanks</p>
  
  <p>Raj<br>
  <strong>EDITED</strong> TRYING TO IMPLEMENT DAVE'S APPROACH, CAN SOMEBODY COMMENT ON MY IMPLEMTATION. I couldn't continue to the bitblt as i donot have two HDC, i donot know how to get this one? Any help please</p>
  
  <pre><code>DisplayDataToImageOnScreen(unsigned char* vInBuff, int vImageSz)  // buffer with pixel data, Size of pixel data
  {
  unsigned char* vImageBuff = NULL;
  
  HDC hdcMem=CreateCompatibleDC(NULL); 
  
  HBITMAP hBitmap = CreateDIBSection(hdcMem, 
                                     (BITMAPINFO*)&amp;vBmih, 
                                     DIB_RGB_COLORS,
                                     (void **)&amp;vImageBuff, 
                                     NULL, 0);
  
  GetDIBits(hdcMem,
            hBitmap,
                 0,
                 1,
           (void**)&amp;vImageBuff,
           (BITMAPINFO*)&amp;vBmih,
           DIB_RGB_COLORS);
  
  memcpy(vImageBuff,vInBuff,vImageSz);
  
  }
  </code></pre>