Old fashion design for PC-104
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

194 lines
5.0 KiB

//----------------------------------------------------------------------------
// Laser Guard Ltd.
// Copyright © 2000-2002. All Rights Reserved.
// Version 1.0 24/03/2000
// Last modification: 08/10/2003
// Project Intruder Position Indicator
// SUBSYSTEM: Video camera showing and captiring window
// FILE: VideoForWindowsWnd.cpp
// AUTHOR: Chizhevskiy Sergey
// OVERVIEW
// ~~~~~~~~
// Source file for implementation of class CVideoForWindowsWnd
//----------------------------------------------------------------------------
#include "stdafx.h"
#include "..\LgLib\Version.h"
/*
#include "VideoForWindowsWnd.h"
CVideoForWindowsWnd::CVideoForWindowsWnd()
{
m_hVFWWnd = 0;
m_IsInitiated = FALSE;
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CVideoForWindowsWnd::CVideoForWindowsWnd" );
}
CVideoForWindowsWnd::CVideoForWindowsWnd( HWND hParentWnd, LPPOINT pPoint, LPSIZE pSize )
{
m_hVFWWnd = 0;
m_IsInitiated = FALSE;
Create(hParentWnd, pPoint, pSize);
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CVideoForWindowsWnd::CVideoForWindowsWnd(...)" );
}
CVideoForWindowsWnd::~CVideoForWindowsWnd()
{
if(m_IsInitiated)
{
if(::IsWindow(m_hVFWWnd))
{
capOverlay( m_hVFWWnd, FALSE );
capDriverDisconnect( m_hVFWWnd );
}
}
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CVideoForWindowsWnd::~CVideoForWindowsWnd" );
}
BOOL CVideoForWindowsWnd::Create(HWND hParentWnd, LPPOINT pPoint, LPSIZE pSize)
{
if(!m_IsInitiated)
{
POINT point = {0, 0};
SIZE size = { GetSafeBmi().bmiHeader.biWidth,
GetSafeBmi().bmiHeader.biHeight };
if(pPoint)
point = *pPoint;
if(pSize)
size = *pSize;
for(INT iIndex = 0; iIndex < 10; iIndex++)
{
TCHAR pDriverName[DESCRIPTION_SIZE];
TCHAR pDriverVer[DESCRIPTION_SIZE];
if(capGetDriverDescription(iIndex, pDriverName, DESCRIPTION_SIZE, pDriverVer, DESCRIPTION_SIZE))
{
m_hVFWWnd = capCreateCaptureWindow("", WS_CHILD, point.x, point.y, size.cx, size.cy, hParentWnd, 1);
if(m_hVFWWnd)
{
if(capDriverConnect(m_hVFWWnd, iIndex))
{
if(capSetVideoFormat(m_hVFWWnd, &GetSafeBmi(), sizeof(BITMAPINFOHEADER)))
{
if(capOverlay(m_hVFWWnd, TRUE))
{
::ShowWindow(m_hVFWWnd, SW_SHOW);
::UpdateWindow(m_hVFWWnd);
return m_IsInitiated = TRUE;
}
}
} // if(capDriverConnect(m_hVFWWnd, iIndex))
} // end of if(m_hVFWWnd)
} // end of if(capGetDriverDescription(
} // end of for(INT iIndex = 0; iIndex < 10; iIndex++)
m_hVFWWnd = NULL;
} // end of if(!m_IsInitiated)
return m_IsInitiated = FALSE;
}
HBITMAP CVideoForWindowsWnd::StoreImage( HANDLE hFile, LPCTSTR pBuffer, INT nBitCount )
{
volatile static BOOL fInside = FALSE;
HBITMAP fSuccess = NULL;
if(!fInside)
{
fInside = TRUE;
if(m_IsInitiated && hFile)
{
capEditCopy(m_hVFWWnd);// Copy the contents of the video frame buffer and
// associated palette to the clipboard.
if(::OpenClipboard(m_hVFWWnd))
{
HBITMAP hDib = (HBITMAP)::GetClipboardData(CF_DIB);
if(hDib)
{
LPBYTE lpDIBByte = ((LPBYTE)::GlobalLock((HGLOBAL)hDib)) + sizeof(BITMAPINFOHEADER);
LPBYTE lpDst = GetSafeBytes();
LPBYTE lpSrc = lpDIBByte;
int lenDst = WIDTHBYTES(GetSafeBmi().bmiHeader.biWidth * 8);
int lenSrc = WIDTHBYTES(GetSafeBmi().bmiHeader.biWidth * GetSafeBmi().bmiHeader.biBitCount);
for(int y = 0; y < GetSafeBmi().bmiHeader.biHeight; y++, lpDst += lenDst, lpSrc += lenSrc)
{
LPBYTE pDst = lpDst;
LPBYTE pSrc = lpSrc;
for(int x = 0; x < lenDst; x++, pSrc += 3)
*pDst++ = (BYTE)((pSrc[0] >>3 ) + (pSrc[1] >> 1) + (pSrc[2] >> 2) + 33);
}
DrawText8( &GetSafeBmi(), GetSafeBytes(), pBuffer );
DWORD dwWritten;
::WriteFile(hFile, GetSafeBytes(), WIDTHBYTES(GetSafeBmi().bmiHeader.biWidth * 8) *
GetSafeBmi().bmiHeader.biHeight, &dwWritten, NULL);
::GlobalUnlock((HGLOBAL)hDib);
fSuccess = (HBITMAP)CopyImage(::GetClipboardData(CF_BITMAP),
IMAGE_BITMAP, 0, 0, LR_COPYRETURNORG);
} // end of if(hDib)
::EmptyClipboard();
::CloseClipboard();
} // end of if(::OpenClipboard(m_hVFWWnd))
} // end of if(m_IsInitiated && hFile)
fInside = FALSE;
} // end of if(!fInside)
return fSuccess;
}
HBITMAP CVideoForWindowsWnd::GetSnapshot()
{
volatile static BOOL fInside = FALSE;
HBITMAP fSuccess = NULL;
if( !fInside )
{
fInside = TRUE;
if(m_IsInitiated)
{
capEditCopy(m_hVFWWnd);
if(::OpenClipboard(m_hVFWWnd))
{
fSuccess = (HBITMAP)::CopyImage( ::GetClipboardData(CF_BITMAP), IMAGE_BITMAP, 0, 0, LR_COPYRETURNORG );
::EmptyClipboard();
::CloseClipboard();
}
}
fInside = FALSE;
}
return fSuccess;
}
BOOL CVideoForWindowsWnd::ShowWindow(int nShow)
{
::ShowWindow( m_hVFWWnd, nShow );
return TRUE;
}
*/