title: WIN32: Getting a blank screen when trying to display an image
body: <p>I am trying to use the WIN32 API for displaying an image on a simple window created. I am filling every byte with a constant value of 100. But nothing is getting displayed on the window. I am working on a 16-bit display. The below is my code. Any help would be much appreciated:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  #include &lt;windows.h&gt;
  
  LRESULT CALLBACK EventProcessor (HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
  { return(DefWindowProc(hWnd,uMsg,wParam,lParam)); }
  
  int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,int nCmdShow)
  {
  WNDCLASS        wc;
  HWND            WindowHandle;
  int         ROWS = 512,COLS=512;
  unsigned char   *disp;
  BITMAPINFO      *bm_info;
  HDC         hDC;
  int i;
  
  wc.style=CS_HREDRAW | CS_VREDRAW;
  wc.lpfnWndProc=(WNDPROC)EventProcessor;
  wc.cbClsExtra=wc.cbWndExtra=0;
  wc.hInstance=hInstance;
  wc.hIcon=wc.lpszMenuName=NULL;
  wc.hCursor=LoadCursor(NULL,IDC_ARROW);
  wc.hbrBackground=(HBRUSH)(COLOR_WINDOW+1);
  wc.lpszClassName="Image Window Class";
  if (RegisterClass(&amp;wc) == 0)
    exit(0);
  
  WindowHandle=CreateWindow("Image Window Class","Demo",
                            WS_OVERLAPPEDWINDOW,
                            10,10,COLS,ROWS,
                            NULL,NULL,hInstance,NULL);
  if (WindowHandle == NULL)
    {
    MessageBox(NULL,"No window","Try again",MB_OK | MB_APPLMODAL);
    exit(0);
    }
  ShowWindow (WindowHandle, SW_SHOWNORMAL);
  
  bm_info=(BITMAPINFO *)calloc(1,sizeof(BITMAPINFO) + 256*sizeof(RGBQUAD));
  hDC=GetDC(WindowHandle);
  
  /* ... set up bmiHeader field of bm_info ... */
  
  for (i=0; i&lt;256; i++)   /* colormap */
    {
    bm_info-&gt;bmiColors[i].rgbBlue=bm_info-&gt;bmiColors[i].rgbGreen=bm_info-&gt;bmiColors[i].rgbRed=i;
    bm_info-&gt;bmiColors[i].rgbReserved=0;
    } 
  disp = (unsigned char*)calloc(1, ROWS*COLS*2);
  
  for(i=0; i&lt;ROWS*COLS*2;++i)
  {
      disp[i] = 100;
  }
  
  SetDIBitsToDevice(hDC,0,0,COLS,ROWS,0,0,
                0, /* first scan line */
                COLS, /* number of scan lines */
                disp,bm_info,DIB_RGB_COLORS);
  
  
  ReleaseDC(WindowHandle,hDC);
  
  free(bm_info);
  MessageBox(NULL,"Press OK to continue","",MB_OK | MB_APPLMODAL);
  }
  </code></pre>
  
  <p>Thanks</p>