Hi!
In my program MFC Doc/view one view constantly displaying what the camera is "seeing". After some event I want to show in the other window - dialog the image that has been in the view in the moment of event.
I have code in Dialog window that succesfully draws pictures from disk. However it starts it's work with Handle and "LoadImage". When I try to pass a HANDLE from view no errors occure but no picture displays. The same situation when I pass CBitmap * with some modification of code.
Exploring structures I found that every bit of data like "Height", "Width" goes fine. But it seemed to me that there are some problems with pointer to picture data. Si I decided to copy data from pointer in view to pointer of picture data in dialog manualy with memcpy()
void CEx07bView::OnAppAbout()
{
CClientDC dc(this);
CBitmap *pB;
BITMAP bm;
pB = dc.GetCurrentBitmap();
pB->GetObject(sizeof(bm),(LPSTR)&bm);
CAboutDlg aboutDlg(bm); //bm - just some flag for tetsing
aboutDlg.picture.tBm.bmBitsPixel = bm.bmBitsPixel;
aboutDlg.picture.tBm.bmHeight = bm.bmHeight;
aboutDlg.picture.tBm.bmPlanes = bm.bmPlanes;
aboutDlg.picture.tBm.bmType = bm.bmType;
aboutDlg.picture.tBm.bmWidth = bm.bmWidth;
aboutDlg.picture.tBm.bmWidthBytes = bm.bmWidthBytes;
memcpy(aboutDlg.picture.tBm.bmBits,bm.bmBits,((((aboutDlg.picture.tBm.bmWidth * (aboutDlg.picture.tBm.bmPlanes * aboutDlg.picture.tBm.bmBitsPixel)) + 31) & ~31) / 8)* aboutDlg.picture.tBm.bmHeight);
aboutDlg.DoModal();
}
And when I get "Access violation writing location 0x000000a4". 0x000000a4 - is the start address of tBm.bmBits by the way.
So questions)
What can be a good conception of realising my idea, generally? Did I choose right strategy or i should solve this problems in some other way? Just In common words, can someone show me the goodstyle direction or so?
And just practice question about this violation in memcpy. Howto copy this bits correctly in physically another memory in ohter structure?
Thanks in advance!