//---------------------------------------------------------------------------- // 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: VideoWnd.cpp // AUTHOR: Chizhevskiy Sergey // OVERVIEW // ~~~~~~~~ // Source file for implementation of class CVideoWnd //---------------------------------------------------------------------------- #include "stdafx.h" #include "..\LgLib\Version.h" #include "VideoWnd.h" CVideoWnd::CVideoWnd() { m_pProfile = NULL; LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CVideoWnd::CVideoWnd" ); } CVideoWnd::~CVideoWnd() { LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CVideoWnd::~CVideoWnd" ); } BYTE CVideoWnd::s_pNumbers[] = { // '0' 0,1,1,0,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,0,1,1,0, // '1' 0,0,0,1,0,0,0,1,0,0,0,1,0,0,1,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1, // '2' 0,1,1,0,1,0,0,1,1,0,0,1,0,0,0,1,0,0,0,1,0,1,1,0,1,0,0,0,1,1,1,1, // '3' 0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,0,0,0,1,1,0,0,1,1,0,0,1,0,1,1,0, // '4' 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,0,0,1,1,1,1,1,0,0,0,1,0,0,0,1, // '5' 0,1,1,1,1,0,0,0,1,1,1,0,1,0,0,1,0,0,0,1,0,0,0,1,1,0,0,1,0,1,1,0, // '6' 0,1,1,0,1,0,0,1,1,0,0,0,1,1,1,0,1,0,0,1,1,0,0,1,1,0,0,1,0,1,1,0, // '7' 1,1,1,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,1,0,0,1,0,0,0,1,0,0,0,1,0,0, // '8' 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0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1, 1,1,1,0, // 'L' - 23 1,0,0,0, 1,0,0,0, 1,0,0,0, 1,0,0,0, 1,0,0,0, 1,0,0,0, 1,0,0,0, 1,1,1,1, // 'I' - 24 0,1,0,0, 0,1,0,0, 0,1,0,0, 0,1,0,0, 0,1,0,0, 0,1,0,0, 0,1,0,0, 0,1,0,0, // 'N' - 25 1,0,0,1, 1,0,0,1, 1,1,0,1, 1,1,0,1, 1,0,1,1, 1,0,1,1, 1,0,0,1, 1,0,0,1, // 'F' - 26 1,1,1,0, 1,0,0,0, 1,0,0,0, 1,0,0,0, 1,1,1,0, 1,0,0,0, 1,0,0,0, 1,0,0,0, // 'X' - 27 1,0,1,0, 1,0,1,0, 1,0,1,0, 0,1,0,0, 1,0,1,0, 1,0,1,0, 1,0,1,0, 1,0,1,0, // 'Z' - 28 1,1,1,0, 0,0,1,0, 0,0,1,0, 0,1,0,0, 0,1,0,0, 1,0,0,0, 1,0,0,0, 1,1,1,0, // '.' - 29 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,1,1,0, 0,1,1,0, 0,0,0,0, // 'E' - 30 1,1,1,0, 1,0,0,0, 1,0,0,0, 1,1,1,0, 1,0,0,0, 1,0,0,0, 1,0,0,0, 1,1,1,0, }; BOOL CVideoWnd::Create( BOOL bStretchVideo, HWND hParentWnd, INT x, INT y, INT cx, INT cy, CProfile *pProfile ) { m_pProfile = pProfile; return TRUE; } BYTE MaxDif( BYTE n ) { INT t = 254 - n; return ( t > n ) ? 254 : 0; } void CVideoWnd::DrawText24( LPBITMAPINFO pBmi, LPBYTE pBytes, LPCTSTR pBuffer) { if( !pBmi ) return; if( !pBytes ) return; LPBYTE lpDst = pBytes; int lenDst = WIDTHBYTES( pBmi->bmiHeader.biWidth * 24 ); int spWidth = 5 * _tcslen(pBuffer); int spHeight = 8; int spPos = ((384 - spWidth * 2 ) / 2 - 1) * 3; LPBYTE lpDst1 = pBytes + spPos; LPBYTE lpDst2 = pBytes + spPos + lenDst; lenDst <<= 1; LPBYTE pNumbers = s_pNumbers + 32 - 4; for( int y = 0; y < spHeight; y++, lpDst1 += lenDst, lpDst2 += lenDst, pNumbers -= 4) { BYTE sl = 0; for(int x = 0, xx = 0; x < spWidth; x++, xx += 6 ) { if(sl < 4) { LPBYTE pByte = pNumbers + sl; BYTE i = pBuffer[x / 5]; switch(i) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': pByte += ((i - '0') << 5); break; case ' ': pByte += (10 << 5); break; case ':': pByte += (11 << 5); break; case '\\': pByte += (12 << 5); break; case 176: pByte += (13 << 5); break; case 'm': pByte += (14 << 5); break; case 'D': pByte += (15 << 5); break; case 'R': pByte += (16 << 5); break; case '!': pByte += (17 << 5); break; case 'P': pByte += (18 << 5); break; case 'H': pByte += (19 << 5); break; case 'O': pByte += (20 << 5); break; case 'T': pByte += (21 << 5); break; case 'B': pByte += (22 << 5); break; case 'L': pByte += (23 << 5); break; case 'I': pByte += (24 << 5); break; case 'N': pByte += (25 << 5); break; case 'F': pByte += (26 << 5); break; case 'X': pByte += (27 << 5); break; case 'Z': pByte += (28 << 5); break; case '.': case ',': pByte += (29 << 5); break; case 'E': case 'e': pByte += (30 << 5); break; } // end of switch(i) if(*pByte) { lpDst1[xx] = lpDst2[xx ] = 0; lpDst1[xx + 1] = lpDst2[xx + 1] = 0; lpDst1[xx + 2] = lpDst2[xx + 2] = 255; lpDst1[xx + 3] = lpDst2[xx + 3] = 0; lpDst1[xx + 4] = lpDst2[xx + 4] = 0; lpDst1[xx + 5] = lpDst2[xx + 5] = 255; } sl++; } // end of if(sl < 4) else sl = 0; } // end of for x } // end of for y } void CVideoWnd::DrawText8( LPBITMAPINFO pBmi, LPBYTE pBytes, LPCTSTR pBuffer ) { if( !pBmi ) return; if( !pBytes ) return; LPBYTE lpDst = pBytes; int lenDst = WIDTHBYTES( pBmi->bmiHeader.biWidth * 8); int spWidth = 5 * _tcslen(pBuffer); int spHeight = 8; int spPos = (384 - spWidth * 2 ) / 2 - 1; LPBYTE lpDst1 = pBytes + spPos; LPBYTE lpDst2 = pBytes + spPos + lenDst; lenDst <<= 1; LPBYTE pNumbers = s_pNumbers + 32 - 4; for( int y = 0; y < spHeight; y++, lpDst1 += lenDst, lpDst2 += lenDst, pNumbers -= 4) { BYTE sl = 0; for(int x = 0, xx = 0; x < spWidth; x++, xx += 2) { if(sl < 4) { LPBYTE pByte = pNumbers + sl; BYTE i = pBuffer[x / 5]; switch(i) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': pByte += ((i - '0') << 5); break; case ' ': pByte += (10 << 5); break; case ':': pByte += (11 << 5); break; case '\\': pByte += (12 << 5); break; case 176: pByte += (13 << 5); break; case 'm': pByte += (14 << 5); break; case 'D': pByte += (15 << 5); break; case 'R': pByte += (16 << 5); break; case '!': pByte += (17 << 5); break; case 'P': pByte += (18 << 5); break; case 'H': pByte += (19 << 5); break; case 'O': pByte += (20 << 5); break; case 'T': pByte += (21 << 5); break; case 'B': pByte += (22 << 5); break; case 'L': pByte += (23 << 5); break; case 'I': pByte += (24 << 5); break; case 'N': pByte += (25 << 5); break; case 'F': pByte += (26 << 5); break; case 'X': pByte += (27 << 5); break; case 'Z': pByte += (28 << 5); break; case '.': case ',': pByte += (29 << 5); break; } // end of switch(i) if(*pByte) { lpDst1[xx] = lpDst2[xx] = lpDst1[xx + 1] = lpDst2[xx + 1] = 255; /* lpDst1[xx] = MaxDif( lpDst1[xx] ); lpDst2[xx] = MaxDif( lpDst2[xx] ); lpDst1[xx + 1] = MaxDif( lpDst1[xx + 1] ); lpDst2[xx + 1] = MaxDif( lpDst2[xx + 1] ); */ } sl++; } // end of if(sl < 4) else sl = 0; } // end of for x } // end of for y }