Changeset 257

User picture

Author: alax

(2011/04/25 21:56) About 1 year ago

added /o switch for ICOpen/ICGetInfo data, /c to show compressor choice UI

Affected files

Updated trunk/EnumerateVcmCodecs/EnumerateVcmCodecs.cpp Download diff

256257
50
	if(nValue & ~nNamedValue)
50
	if(nValue & ~nNamedValue)
51
	{
51
	{
52
		if(!sText.IsEmpty())
52
		if(!sText.IsEmpty())
53
			sText.Append(_T(" |"));
53
			sText.Append(_T(" | "));
54
		sText.AppendFormat(_T("0x%x"), nValue & ~nNamedValue);
54
		sText.AppendFormat(_T("0x%x"), nValue & ~nNamedValue);
55
	}
55
	}
56
	if(sText.IsEmpty())
56
	if(sText.IsEmpty())
...
...
58
	return sText;
58
	return sText;
59
}
59
}
60
60
61
VOID Print(const ICINFO& Information, LPCTSTR pszName, LPCTSTR pszPrefix = _T(""))
62
{
63
	_tprintf(
64
		_T("%s") _T("%s: szName %ls\n")
65
		_T("%s") _T("  fccType %s, fccHandler %s\n")
66
		_T("%s") _T("  dwFlags %s\n")
67
		_T("%s") _T("  dwVersion 0x%x, dwVersionICM 0x%x\n")
68
		_T("%s") _T("  szDescription \"%ls\"\n")
69
		_T("%s") _T("  szDriver \"%ls\"\n")
70
		, 
71
		pszPrefix, pszName, (LPCWSTR) Information.szName,
72
		pszPrefix, StringFromFourcc(Information.fccType), StringFromFourcc(Information.fccHandler),
73
		pszPrefix, StringFromFlags(Information.dwFlags),
74
		pszPrefix, Information.dwVersion, Information.dwVersionICM,
75
		pszPrefix, (LPCWSTR) Information.szDescription,
76
		pszPrefix, (LPCWSTR) Information.szDriver,
77
		0);
78
}
79
61
int _tmain(int argc, _TCHAR* argv[])
80
int _tmain(int argc, _TCHAR* argv[])
62
{
81
{
63
	_ATLTRY
82
	_ATLTRY
64
	{
83
	{
84
		#pragma region Command-Line Arguments
85
		BOOL bOpen = FALSE;
86
		BOOL bCompressorChooose = FALSE;
87
		for(int nIndex = 1; nIndex < argc; nIndex++)
88
		{
89
			CString sArgument = argv[nIndex];
90
			_A(!sArgument.IsEmpty());
91
			if(_tcschr(_T("-/"), sArgument[0]))
92
			{
93
				sArgument.Delete(0);
94
				if(sArgument.CompareNoCase(_T("o")) == 0)
95
				{
96
					bOpen = TRUE;
97
				} else
98
				if(sArgument.CompareNoCase(_T("c")) == 0)
99
				{
100
					bCompressorChooose = TRUE;
101
				} else
102
					__C(E_INVALIDARG);
103
			} else
104
				__C(E_INVALIDARG);
105
		}
106
		#pragma endregion
65
		for(UINT nIndex = 0; ; nIndex++)
107
		for(UINT nIndex = 0; ; nIndex++)
66
		{
108
		{
109
			#pragma region ICInfo
67
			ICINFO Information;
110
			ICINFO Information;
68
			ZeroMemory(&Information, sizeof Information);
111
			ZeroMemory(&Information, sizeof Information);
69
			Information.dwSize = sizeof Information;
112
			Information.dwSize = sizeof Information;
70
			if(!ICInfo(0, nIndex, &Information))
113
			if(!ICInfo(0, nIndex, &Information))
71
				break;
114
				break;
72
			_tprintf(
115
			Print(Information, _T("ICInfo"));
73
				_T("szName %ls\n")
116
			#pragma endregion 
74
				_T("  fccType: %s, fccHandler %s\n")
117
			#pragma region ICOpen
75
				_T("  dwFlags %s\n")
118
			if(!bOpen)
76
				_T("  dwVersion 0x%x, dwVersionICM 0x%x\n")
119
				continue;
77
				_T("  szDescription \"%ls\"\n")
120
			static const struct
78
				_T("  szDriver \"%ls\"\n")
121
			{
79
				, 
122
				UINT nMode;
80
				(LPCWSTR) Information.szName,
123
				LPCTSTR pszName;
81
				StringFromFourcc(Information.fccType), StringFromFourcc(Information.fccHandler),
124
			} g_pModes[] = 
82
				StringFromFlags(Information.dwFlags),
125
			{
83
				Information.dwVersion, Information.dwVersionICM,
126
				{ ICMODE_COMPRESS, _T("ICMODE_COMPRESS") },
84
				(LPCWSTR) Information.szDescription,
127
				{ ICMODE_DECOMPRESS, _T("ICMODE_DECOMPRESS") },
85
				(LPCWSTR) Information.szDriver,
128
				{ ICMODE_FASTDECOMPRESS, _T("ICMODE_FASTDECOMPRESS") },
86
				0);
129
				{ ICMODE_QUERY, _T("ICMODE_QUERY") },
130
				{ ICMODE_FASTCOMPRESS, _T("ICMODE_FASTCOMPRESS") },
131
			};
132
			for(SIZE_T nIndex = 0; nIndex < DIM(g_pModes); nIndex++)
133
			{
134
				HIC hImageCompressor = ICOpen(Information.fccType, Information.fccHandler, g_pModes[nIndex].nMode);
135
				if(!hImageCompressor)
136
					continue;
137
				_tprintf(_T("    ") _T("ICOpen: wMode %s (%d)\n"), g_pModes[nIndex].pszName, g_pModes[nIndex].nMode);
138
				#pragma region ICGetInfo
139
				ICINFO Information;
140
				ZeroMemory(&Information, sizeof Information);
141
				Information.dwSize = sizeof Information;
142
				if(ICGetInfo(hImageCompressor, &Information, sizeof Information))
143
					Print(Information, _T("ICGetInfo"), _T("      "));
144
				#pragma endregion 
145
				_W(ICClose(hImageCompressor) == ICERR_OK);
146
			}
147
			#pragma endregion 
87
		}
148
		}
149
		if(bCompressorChooose)
150
		{
151
			COMPVARS CompressionVaraibles;
152
			ZeroMemory(&CompressionVaraibles, sizeof CompressionVaraibles);
153
			CompressionVaraibles.cbSize = sizeof CompressionVaraibles;
154
			ICCompressorChoose(GetActiveWindow(), ICMF_CHOOSE_ALLCOMPRESSORS, NULL, NULL, &CompressionVaraibles, NULL);
155
		}
88
	}
156
	}
89
	_ATLCATCH(Exception)
157
	_ATLCATCH(Exception)
90
	{
158
	{