1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
void CDrawing2BitmapDlg::Draw()
{
CDC* pDC = GetDC();
if(initialisation)
{
CBitmap *OldBitmap;
CBitmap *Bitmap;
if(pDC != NULL)
{
if(bViewCol)
Bild = Cam->GetBmpHandle(1); // get HBITMAP from csensi-object
else
Bild = Cam->GetBmpHandle(0);
bShow = TRUE;
if(Bild)
{
CDC *dcmem; // create memory DC
dcmem = new CDC();
dcmem->CreateCompatibleDC(pDC);
if(!bViewCol) // if b/w: set palette to dc (image problems
{ // in color modes other than true color)
Cam->SetBWPalette(pDC);
Cam->SetBWPalette(dcmem);
}
// select Image
Bitmap = OldBitmap->FromHandle(Bild);// misuse OldBitmap to create
OldBitmap = (CBitmap*)dcmem->SelectObject(Bitmap);
pDC->SetStretchBltMode(HALFTONE); // ou COLORONCOLOR
pDC->StretchBlt(m_rDrawingSurface.left,m_rDrawingSurface.top,m_rDrawingSurface.Width(),m_rDrawingSurface.Height(),dcmem,0,0,Cam->iXRes,Cam->iYRes,SRCCOPY);
dcmem->DeleteDC(); // delete memory DC to avoid leaks
delete(dcmem);
}
InvalidateRect(NULL);
}
ReleaseDC(pDC);
}
}
void CDrawing2BitmapDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CDrawing2BitmapDlg::OnPaint()
{
CDialog::OnPaint();
Draw();
}
void CDrawing2BitmapDlg::OnInitialisation()
{
// TODO: Add your control notification handler code here
mydc = new CPaintDC(this);
mymemdc = new CDC();
mymemdc->CreateCompatibleDC(mydc);
Cam = new CSensiEFS(mydc,mymemdc); // create camera object
int err=Cam->InitEFS();
initialisation=TRUE;
}
void CDrawing2BitmapDlg::OnAcquisition()
{
// TODO: Add your control notification handler code here
if(!bSerie)
{
hTimer = timeSetEvent(10,10,Timer,(unsigned long) this,TIME_PERIODIC|TIME_CALLBACK_FUNCTION);
Cam->StartSeqEFS(); // prepare for sequenz
bSerie = TRUE;
}
else
{
Cam->StopSeq(); // stop sequenz
bSerie = FALSE;
bNewPic = FALSE;
bSerie = FALSE;
timeKillEvent(hTimer);
}
} |
Partager