sir, i got a error.. "GetDC' : function does not take 1 parameters" how about it??
josipahutar
Posts
-
Save image from picturebox use MFC -
Create Bitmap from mousemovement in picturebox MFCthx your reply sir.. i dont understand because i newbie in MFC.. :confused: so can u give me a example about my problem... Regard's Johannes
-
Create Bitmap from mousemovement in picturebox MFChi guys,,, i'm have a project about MFC. how to create bitmap from mousemovent?? for mousemovent i'm can write to picturebox. the code is written in mfc wizard exe in a dialog based application. for picturebox -> IDC_PIC for button -> IDC_SAVE my code: void CSignature1Dlg::OnMouseMove(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default m_pic1.GetSafeHwnd(); HCURSOR hcur = NULL; CRect rc; m_pic1.GetClientRect(&rc); rc.NormalizeRect(); rc.left=0; rc.right=250; rc.top=0; rc.bottom=250; POINT MousePosition = point; BOOL isOnPictureControl = PtInRect(&rc, MousePosition); if((m_iPrevX >=rc.left && m_iPrevX <=rc.right) && (m_iPrevY >=rc.top && m_iPrevY <=rc.bottom )){ if((nFlags & MK_LBUTTON) == MK_LBUTTON) { CDC* pDC = m_pic1.GetDC(); CDC dcMem; dcMem.CreateCompatibleDC(pDC); dcMem.SelectObject(&m_bmpBitmap); CPen pen (PS_SOLID,2,RGB(0,0,0)); pDC->SelectObject (&pen); pDC->MoveTo(m_iPrevX,m_iPrevY); pDC->LineTo(point.x,point.y); pDC->SetPixel(point.x,point.y, RGB(0,0,0)) ; m_iPrevX=point.x; m_iPrevY=point.y; } } CDialog::OnMouseMove(nFlags, point); } void CSignature1Dlg::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default HCURSOR hcur = NULL; CRect rc; m_pic1.GetClientRect(&rc); rc.NormalizeRect(); m_iPrevX=point.x; m_iPrevY=point.y; CDialog::OnLButtonDown(nFlags, point); } void CSignature1Dlg::OnSave() { // TODO: Add your control notification handler code here ????????? } so give me advice, how to can create and save the mousemovent into bitmap??? :confused: i hope u can help me... :|
-
Save image from picturebox use MFCThx sir.. but i dont understand.. Can you explain in detail the program... Regard Johannes
-
Save image from picturebox use MFCthx for your answer sir.. but after i try the code, i can't find image c://temp.bmp. can u tell me , how to the code work in MFC to save a image di picturebox. my problem : i will load a image to picturebox in MFC then i'm want to save it. can u give sample code about my problem?? Regard's Johannes.
-
Save image from picturebox use MFChi guys,,, i'm a newbie in MFC so i'm need your advice to complete final project about identification signature. in this time i have problem about how to save image from picture box in MFC. this is my code used in MFC. this code not save image from picturebox. what's wrong with my code??? void SaveBitmapToFile( BYTE* pBitmapBits, LONG lWidth, LONG lHeight,WORD wBitsPerPixel, LPCTSTR lpszFileName ); void CSaveimageDlg::OnSave() { // TODO: Add your control notification handler code here CDC *pDC = m_pic1.GetDC(); CDC dcMem1; CRect rect; m_pic1.GetClientRect(rect); HDC hdc; HBITMAP hBitmap = NULL; BITMAP bm; CBitmap Bitmap; m_pic1.SetBitmap(Bitmap); Bitmap.CreateBitmap(200 ,200,1,24,NULL); m_bmpBitmap.GetBitmap(&bm); //Bitmap.GetBitmap(&bm); Bitmap.GetObject( sizeof( BITMAP ), &bm ); unsigned char *pData = new unsigned char [bm.bmHeight*bm.bmWidthBytes]; SaveBitmapToFile(pData,bm.bmHeight,bm.bmWidth,24,(LPCTSTR)_T("a.bmp")); delete []pData; } void CSaveimageDlg::SaveBitmapToFile(BYTE *pBitmapBits, LONG lWidth, LONG lHeight, WORD wBitsPerPixel, LPCTSTR lpszFileName) { BITMAPINFOHEADER bmpInfoHeader = {0}; bmpInfoHeader.biSize = sizeof(BITMAPINFOHEADER); bmpInfoHeader.biBitCount = wBitsPerPixel; bmpInfoHeader.biClrImportant = 0; bmpInfoHeader.biClrUsed = 0; bmpInfoHeader.biCompression = BI_RGB; bmpInfoHeader.biHeight = lHeight; bmpInfoHeader.biWidth = lWidth; bmpInfoHeader.biPlanes = 1; bmpInfoHeader.biSizeImage = lWidth* lHeight * (wBitsPerPixel/8); BITMAPFILEHEADER bfh = {0}; bfh.bfType=0x4D42; bfh.bfType = 'B'+('M' << 8); bfh.bfOffBits = sizeof(BITMAPINFOHEADER) + sizeof(BITMAPFILEHEADER); bfh.bfSize = bfh.bfOffBits + bmpInfoHeader.biSizeImage; HANDLE hFile = CreateFile( lpszFileName,GENERIC_WRITE, 0,NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,NULL); if( !hFile ) // return if error opening file { return; } DWORD dwWritten = 0; WriteFile( hFile, &bfh, sizeof(bfh), &dwWritten , NULL ); WriteFile( hFile, &bmpInfoHeader, sizeof(bmpInfoHeader), &dwWritten, NULL ); WriteFile( hFile, pBitmapBits, bmpInfoHeader.biSizeImage, &dwWritten, NULL ); CloseHandle( hFile ); }