source: trunk/Utilities/MediaDetSnapshot/Module.h @ 292

Last change on this file since 292 was 292, checked in by roman, 10 years ago
File size: 2.5 KB
Line 
1////////////////////////////////////////////////////////////
2// Copyright (C) Roman Ryltsov, 2006-2014
3// Created by Roman Ryltsov roman@alax.info
4//
5// A permission to use the source code is granted as long as reference to
6// source website http://alax.info is retained.
7
8#define __IDxtCompositor_INTERFACE_DEFINED__
9#define __IDxtAlphaSetter_INTERFACE_DEFINED__
10#define __IDxtJpeg_INTERFACE_DEFINED__
11#define __IDxtKey_INTERFACE_DEFINED__
12#include "C:\SDK-6.1\Include\qedit.h"
13
14//#import "libid:B9EC374B-834B-4DA9-BFB5-C1872CE736FF" no_namespace raw_interfaces_only
15#include "rofiles.h"
16#include "rodshow.h"
17
18#pragma once
19
20////////////////////////////////////////////////////////////
21// CModule
22
23class CModule : 
24        public CAtlExeModuleT<CModule>
25{
26public:
27
28private:
29        static CEvent g_TerminationEvent;
30
31public:
32        CPath m_sPath;
33
34public:
35// CModule
36        CModule()
37        {
38                AtlTraceSetDefaultSettings();
39                _Z4_THIS();
40        }
41        ~CModule()
42        {
43                _Z4_THIS();
44        }
45        HRESULT PreMessageLoop(INT nShowCommand)
46        {
47                __C(__super::PreMessageLoop(nShowCommand));
48                return S_OK;
49        }
50        BOOL InternalHandlerRoutine(DWORD nType)
51        {
52                _tprintf(_T("Stopping...\n"));
53                _W(g_TerminationEvent.Set());
54                return TRUE;
55        }
56        static BOOL WINAPI HandlerRoutine(DWORD nType)
57        {
58                return static_cast<CModule*>(_pAtlModule)->InternalHandlerRoutine(nType);
59        }
60        VOID RunMessageLoop()
61        {
62                CComPtr<IMediaDet> pMediaDet;
63                __C(pMediaDet.CoCreateInstance(CLSID_MediaDet));
64                __C(pMediaDet->put_Filename(CComBSTR(m_sPath)));
65                CHeapPtr<BITMAPINFOHEADER> pBitmapInfoHeader;
66                __D(pBitmapInfoHeader.AllocateBytes(8 << 20), E_OUTOFMEMORY); // 8 MB
67                __C(pMediaDet->GetBitmapBits(15.0, NULL, (char*) (BITMAPINFOHEADER*) pBitmapInfoHeader, 640, 480));
68                AtlMessageBox(GetActiveWindow(), _T("Break In"), _T("Debug"), MB_OK);
69                BITMAPFILEHEADER FileHeader;
70                ZeroMemory(&FileHeader, sizeof FileHeader);
71                FileHeader.bfType = 'MB';
72                FileHeader.bfOffBits = sizeof FileHeader + sizeof *pBitmapInfoHeader;
73                FileHeader.bfSize = FileHeader.bfOffBits + pBitmapInfoHeader->biSizeImage;
74                CAtlFile File;
75                static LPCTSTR g_pszBitmapPath = _T("D:\\Output.bmp");
76                __C(File.Create(g_pszBitmapPath, GENERIC_WRITE, FILE_SHARE_READ, CREATE_ALWAYS));
77                __C(File.Write(&FileHeader, sizeof FileHeader));
78                __C(File.Write(pBitmapInfoHeader, FileHeader.bfSize - sizeof FileHeader));
79                //__E(g_TerminationEvent.Create(NULL, TRUE, FALSE, NULL));
80                //__E(SetConsoleCtrlHandler(&CModule::HandlerRoutine, TRUE));
81                //...
82        }
83};
84
85__declspec(selectany) CEvent CModule::g_TerminationEvent;
Note: See TracBrowser for help on using the repository browser.