void CFileOpenDlg::OnBnClickedButton2() { CRect r; CBitmap* m_bitmap; CDC dc, *pDC; BITMAP bmp; m_bitmap = new CBitmap(); m_bitmap->LoadBitmapW(IDB_BITMAP1); m_bitmap->GetBitmap(&bmp); pDC = this->GetDC(); dc.CreateCompatibleDC(pDC); dc.SelectObject(m_bitmap); pDC->BitBlt(200, 200, bmp.bmWidth, bmp.bmHeight, &dc,0 , 0, SRCCOPY); m_bitmap->DeleteObject(); m_bitmap->Detach() }
error C2065:'IDB_BITMAP' : undeclared identifier
oh i got my mistake. i should use image name in place of 'IDB_BITMAP1' which is returned by browse button. browse button code is void CFileOpenDlg::OnBnClickedButton1() { CFileDialog dlg(TRUE); int result=dlg.DoModal(); if(result==IDOK) { path=dlg.GetPathName(); UpdateData(FALSE); } } so i replace 'IDB_BITMAP1' by path. program build successfully but i dont get image on clicking ok button :(
plz see whats missing in it? void CFileOpenDlg::OnBnClickedButton2() { // TODO: Add your control notification handler code here HANDLE hBitMap = ::LoadImage(0, path,IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); CBitmap bmp; bmp.Attach((HBITMAP)hBitMap); // handle you got from LoadBitmap BITMAP bitmap; bmp.GetBitmap(&bitmap); int size = bitmap.bmHeight*bitmap.bmWidth*bitmap.bmBitsPixel/8; BYTE *lpBits = new BYTE[ size ]; ::GetBitmapBits((HBITMAP)hBitMap,size,lpBits ); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)