Go4Expert

Go4Expert (http://www.go4expert.com/)
-   MFC (http://www.go4expert.com/forums/mfc/)
-   -   Display_Bitmap_Image (http://www.go4expert.com/forums/displaybitmapimage-t24134/)

MFC New Bee 9Dec2010 22:18

Display_Bitmap_Image
 
Hi all,
I am creating an application named 'BmpViewer' in which the user can view the bitmap , copy the bitmap on the new file , save the bitmap as normal or black and white . Also a provision is to be given to view the bitmap in different modes of colours, like red, blue, green and gray.So far i have read the bmp file but i have no idea about how to display the image without using the HBITMAP. Below is my code.
Code:

BOOL CBmpInfoDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
 FILE *fp;
 fp = _wfopen(lpszPathName , (const wchar_t*) "r");
 if(fp == NULL)
 {
  return FALSE;
 }
 m_pbmiColors = new RGBQUAD[256];
 ZeroMemory(&m_bmfhFileHeader, sizeof(m_bmfhFileHeader));
 fread(&m_bmfhFileHeader , sizeof(BITMAPFILEHEADER) ,  1 ,fp);
 
 fread(&m_bmiInfoHead , sizeof(BITMAPINFOHEADER) , 1 , fp);
 int nNoOfPalette = pow(double(2) , double(m_bmiInfoHead.biBitCount));
 if(m_bmiInfoHead.biBitCount <= 8)
 {
  for(int nId = 0 ; nId < nNoOfPalette ; nId++)
  {
  fread(&m_pbmiColors[nId].rgbBlue    , sizeof(m_pbmiColors) , 1 , fp);
  fread(&m_pbmiColors[nId].rgbGreen      , sizeof(m_pbmiColors) , 1 , fp);
  fread(&m_pbmiColors[nId].rgbRed    , sizeof(m_pbmiColors) , 1 , fp);
  fread(&m_pbmiColors[nId].rgbReserved  , sizeof(m_pbmiColors) , 1 , fp);
  }
 }
 int nSize = WIDTHBYTES((m_bmiInfoHead.biWidth)    *
        ((DWORD)m_bmiInfoHead.biBitCount)) *
      m_bmiInfoHead.biHeight;
                 
 m_bmBits = new BYTE[nSize];
 fread(&m_bmBits , sizeof(m_bmBits) , 1 , fp);
 m_bFlag = TRUE;
 return TRUE;
}

Could any one suggest me a way of displaying the image.



All times are GMT +5.5. The time now is 06:14.