case WM_COMMAND: wmId = LOWORD (wParam); wmEvent = HIWORD (wParam); switch (wmId) { case IDM_ABOUT: break; case IDM_EXIT: DestroyWindow (hWnd); break; default: return DefWindowProc (hWnd, message, wParam, lParam); } break; case WM_PAINT: ValidateRect (hWnd , NULL); break; case WM_DESTROY: PostQuitMessage (0); break; default: return DefWindowProc (hWnd, message, wParam, lParam); } return 0;} #endif CUtils::CUtils() { hHandle = NULL; iOSType = CheckOS(); #ifdef ENABLE_DISPLAY_MODULE if (iOSType == OS_XP) hHandle = (void*) new CD3D9Utils; else if (iOSType == OS_VISTA_UPPER) hHandle = (void*) new CD3D9ExUtils;#endif if (hHandle == NULL) iOSType = OS_UNSUPPORTED;} CUtils::~CUtils() {#ifdef ENABLE_DISPLAY_MODULE if (hHandle) { if (iOSType == OS_XP) { CD3D9Utils* hTmp = (CD3D9Utils*) hHandle; delete hTmp; } else if (iOSType == OS_VISTA_UPPER) { CD3D9ExUtils* hTmp = (CD3D9ExUtils*) hHandle; delete hTmp; } hHandle = NULL; }#endif} int CUtils::Process (void* pDst[3], SBufferInfo* pInfo, FILE* pFp) { int iRet = 0; if (iOSType == OS_UNSUPPORTED) { if (pFp && pDst[0] && pDst[1] && pDst[2] && pInfo) { int iStride[2]; int iWidth = pInfo->UsrData.sSystemBuffer.iWidth; int iHeight = pInfo->UsrData.sSystemBuffer.iHeight; iStride[0] = pInfo->UsrData.sSystemBuffer.iStride[0]; iStride[1] = pInfo->UsrData.sSystemBuffer.iStride[1]; Write2File (pFp, (unsigned char**)pDst, iStride, iWidth, iHeight); } } #ifdef ENABLE_DISPLAY_MODULE else { MSG msg; ZeroMemory (&msg, sizeof (msg)); while (msg.message != WM_QUIT) { if (PeekMessage (&msg, NULL, 0U, 0U, PM_REMOVE)) { TranslateMessage (&msg); DispatchMessage (&msg); } else { HRESULT hResult = S_OK; if (iOSType == OS_XP) hResult = ((CD3D9Utils*)hHandle)->Process (pDst, pInfo, pFp); else if (iOSType == OS_VISTA_UPPER) hResult = ((CD3D9ExUtils*)hHandle)->Process (pDst, pInfo, pFp); iRet = !SUCCEEDED (hResult); break; } } }#endif return iRet;} int CUtils::CheckOS() { int iType = OS_UNSUPPORTED; #ifdef ENABLE_DISPLAY_MODULE OSVERSIONINFOEX osvi; ZeroMemory (&osvi, sizeof (OSVERSIONINFOEX)); osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX); if (!GetVersionEx ((OSVERSIONINFO*) &osvi)) { osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); if (! GetVersionEx ((OSVERSIONINFO*) &osvi)) return iType; } switch (osvi.dwPlatformId) { case VER_PLATFORM_WIN32_NT: if (osvi.dwMajorVersion >= 6) iType = OS_VISTA_UPPER; else if (osvi.dwMajorVersion == 5) iType = OS_XP; break; default: break; }#endif return iType;} void Write2File (FILE* pFp, unsigned char* pData[3], int iStride[2], int iWidth, int iHeight) { int i; unsigned char* pPtr = NULL; pPtr = pData[0]; for (i = 0; i < iHeight; i++) { fwrite (pPtr, 1, iWidth, pFp); pPtr += iStride[0]; } iHeight = iHeight / 2; iWidth = iWidth / 2; pPtr = pData[1]; for (i = 0; i < iHeight; i++) { fwrite (pPtr, 1, iWidth, pFp); pPtr += iStride[1]; } pPtr = pData[2]; for (i = 0; i < iHeight; i++) { fwrite (pPtr, 1, iWidth, pFp); pPtr += iStride[1]; }}Lines 501–654 of 654. Previous lines
case WM_COMMAND: wmId = LOWORD (wParam); wmEvent = HIWORD (wParam); switch (wmId) { case IDM_ABOUT: break; case IDM_EXIT: DestroyWindow (hWnd); break; default: return DefWindowProc (hWnd, message, wParam, lParam); } break; case WM_PAINT: ValidateRect (hWnd , NULL); break; case WM_DESTROY: PostQuitMessage (0); break; default: return DefWindowProc (hWnd, message, wParam, lParam); } return 0; } #endif CUtils::CUtils() { hHandle = NULL; iOSType = CheckOS(); #ifdef ENABLE_DISPLAY_MODULE if (iOSType == OS_XP) hHandle = (void*) new CD3D9Utils; else if (iOSType == OS_VISTA_UPPER) hHandle = (void*) new CD3D9ExUtils; #endif if (hHandle == NULL) iOSType = OS_UNSUPPORTED; } CUtils::~CUtils() { #ifdef ENABLE_DISPLAY_MODULE if (hHandle) { if (iOSType == OS_XP) { CD3D9Utils* hTmp = (CD3D9Utils*) hHandle; delete hTmp; } else if (iOSType == OS_VISTA_UPPER) { CD3D9ExUtils* hTmp = (CD3D9ExUtils*) hHandle; delete hTmp; } hHandle = NULL; } #endif } int CUtils::Process (void* pDst[3], SBufferInfo* pInfo, FILE* pFp) { int iRet = 0; if (iOSType == OS_UNSUPPORTED) { if (pFp && pDst[0] && pDst[1] && pDst[2] && pInfo) { int iStride[2]; int iWidth = pInfo->UsrData.sSystemBuffer.iWidth; int iHeight = pInfo->UsrData.sSystemBuffer.iHeight; iStride[0] = pInfo->UsrData.sSystemBuffer.iStride[0]; iStride[1] = pInfo->UsrData.sSystemBuffer.iStride[1]; Write2File (pFp, (unsigned char**)pDst, iStride, iWidth, iHeight); } } #ifdef ENABLE_DISPLAY_MODULE else { MSG msg; ZeroMemory (&msg, sizeof (msg)); while (msg.message != WM_QUIT) { if (PeekMessage (&msg, NULL, 0U, 0U, PM_REMOVE)) { TranslateMessage (&msg); DispatchMessage (&msg); } else { HRESULT hResult = S_OK; if (iOSType == OS_XP) hResult = ((CD3D9Utils*)hHandle)->Process (pDst, pInfo, pFp); else if (iOSType == OS_VISTA_UPPER) hResult = ((CD3D9ExUtils*)hHandle)->Process (pDst, pInfo, pFp); iRet = !SUCCEEDED (hResult); break; } } } #endif return iRet; } int CUtils::CheckOS() { int iType = OS_UNSUPPORTED; #ifdef ENABLE_DISPLAY_MODULE OSVERSIONINFOEX osvi; ZeroMemory (&osvi, sizeof (OSVERSIONINFOEX)); osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX); if (!GetVersionEx ((OSVERSIONINFO*) &osvi)) { osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); if (! GetVersionEx ((OSVERSIONINFO*) &osvi)) return iType; } switch (osvi.dwPlatformId) { case VER_PLATFORM_WIN32_NT: if (osvi.dwMajorVersion >= 6) iType = OS_VISTA_UPPER; else if (osvi.dwMajorVersion == 5) iType = OS_XP; break; default: break; } #endif return iType; } void Write2File (FILE* pFp, unsigned char* pData[3], int iStride[2], int iWidth, int iHeight) { int i; unsigned char* pPtr = NULL; pPtr = pData[0]; for (i = 0; i < iHeight; i++) { fwrite (pPtr, 1, iWidth, pFp); pPtr += iStride[0]; } iHeight = iHeight / 2; iWidth = iWidth / 2; pPtr = pData[1]; for (i = 0; i < iHeight; i++) { fwrite (pPtr, 1, iWidth, pFp); pPtr += iStride[1]; } pPtr = pData[2]; for (i = 0; i < iHeight; i++) { fwrite (pPtr, 1, iWidth, pFp); pPtr += iStride[1]; } }