Menubar problem
-
I use embedded visual c++ to write a video cam software, so that the pocket PC show the screen of the cam. But my menubar does not work.(I tick the top up box) When I click the top up button in menubar, the menubar hangs. But the screen still can show the video. void CGroup7Dlg::OnPreview() { unsigned char *pbuffer = (unsigned char *)malloc(m_PrvWidth * m_PrvHeight * 3); unsigned char *rpbuffer = (unsigned char *)malloc(m_PrvWidth * m_PrvHeight * 3); if ((PreviewFrame((unsigned char*) pbuffer)) == false) AfxMessageBox(_T("Preview Frame Fail!"), MB_OK); Rectify(pbuffer, rpbuffer); //<----- a CBitmap bitmap; bitmap.CreateBitmap(m_PrvWidth, m_PrvHeight, 1, 24, rpbuffer); CVOImage image; RECT pic_rect; m_picture_window.GetWindowRect(&pic_rect); HDC picDC = ::GetDC(m_picture_window.m_hWnd ); CString path_fname; ::WriteBitmapIntoJpegFile(TEXT("\\pic1.jpg"), 80, (HBITMAP)bitmap); UpdateData(true); path_fname ="\\My Documents\\pic1.jpg"; image.Load (picDC ,path_fname ); image.Draw (picDC ,2,13 ); free(pbuffer); pbuffer = NULL; free(rpbuffer); //<-------b rpbuffer = NULL; } There will be out of memory if I comment out line b but menubar works. There will be no problem but the screen pixel is in wrong order of course. I don't know how to fix this bug. Please help...
-
I use embedded visual c++ to write a video cam software, so that the pocket PC show the screen of the cam. But my menubar does not work.(I tick the top up box) When I click the top up button in menubar, the menubar hangs. But the screen still can show the video. void CGroup7Dlg::OnPreview() { unsigned char *pbuffer = (unsigned char *)malloc(m_PrvWidth * m_PrvHeight * 3); unsigned char *rpbuffer = (unsigned char *)malloc(m_PrvWidth * m_PrvHeight * 3); if ((PreviewFrame((unsigned char*) pbuffer)) == false) AfxMessageBox(_T("Preview Frame Fail!"), MB_OK); Rectify(pbuffer, rpbuffer); //<----- a CBitmap bitmap; bitmap.CreateBitmap(m_PrvWidth, m_PrvHeight, 1, 24, rpbuffer); CVOImage image; RECT pic_rect; m_picture_window.GetWindowRect(&pic_rect); HDC picDC = ::GetDC(m_picture_window.m_hWnd ); CString path_fname; ::WriteBitmapIntoJpegFile(TEXT("\\pic1.jpg"), 80, (HBITMAP)bitmap); UpdateData(true); path_fname ="\\My Documents\\pic1.jpg"; image.Load (picDC ,path_fname ); image.Draw (picDC ,2,13 ); free(pbuffer); pbuffer = NULL; free(rpbuffer); //<-------b rpbuffer = NULL; } There will be out of memory if I comment out line b but menubar works. There will be no problem but the screen pixel is in wrong order of course. I don't know how to fix this bug. Please help...
There will be out of memory if I comment out line b but menubar works There will be a memory leak if you did that. Howabout to set your pbuffer and rbuffer as a member variable? And why don't you use new/delete instead of malloc/free? Sonork 100.41263:Anthony_Yio
-
There will be out of memory if I comment out line b but menubar works There will be a memory leak if you did that. Howabout to set your pbuffer and rbuffer as a member variable? And why don't you use new/delete instead of malloc/free? Sonork 100.41263:Anthony_Yio
Thank you so much, I have tried your method: unsigned char *pbuffer = new unsigned char[m_PrvWidth * m_PrvHeight* 6]; unsigned char *rpbuffer = new unsigned char[m_PrvWidth * m_PrvHeight* 6]; . . . delete[] pbuffer; delete[] rpbuffer; But, the same problem is still there. And the "out of memory" dialog pop up continuously..........help.........please Do you have any idea?! >_<
-
Thank you so much, I have tried your method: unsigned char *pbuffer = new unsigned char[m_PrvWidth * m_PrvHeight* 6]; unsigned char *rpbuffer = new unsigned char[m_PrvWidth * m_PrvHeight* 6]; . . . delete[] pbuffer; delete[] rpbuffer; But, the same problem is still there. And the "out of memory" dialog pop up continuously..........help.........please Do you have any idea?! >_<
It could be that there is a memory leak in your program. Try CMemoryState to trace where is it. Sonork 100.41263:Anthony_Yio