Author: bfreisen
Date: Mon Sep 26 19:08:20 2016
New Revision: 72817
URL:
http://svn.reactos.org/svn/reactos?rev=72817&view=rev
Log:
[ATL] CImage: Add GetImporterFilterString and GetExporterFilterString. Patch by Katayama
Hirofumi MZ, CORE-10029
Modified:
trunk/reactos/sdk/lib/atl/atlimage.h
Modified: trunk/reactos/sdk/lib/atl/atlimage.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/atl/atlimage.h?rev…
==============================================================================
--- trunk/reactos/sdk/lib/atl/atlimage.h [iso-8859-1] (original)
+++ trunk/reactos/sdk/lib/atl/atlimage.h [iso-8859-1] Mon Sep 26 19:08:20 2016
@@ -12,12 +12,15 @@
// See rostest/apitests/atl/CImage_WIP.txt for test results.
// !!!!
-// TODO: GetImporterFilterString, GetExporterFilterString, Load, Save
+// TODO: CImage::Load, CImage::Save
// TODO: make CImage thread-safe
#pragma once
-#include <atlcore.h>
+#include <atlcore.h> // for ATL Core
+#include <atlstr.h> // for CAtlStringMgr
+#include <atlsimpstr.h> // for CSimpleString
+#include <atlsimpcoll.h> // for CSimpleArray
#include <wingdi.h>
#include <cguid.h> // for GUID_NULL
@@ -705,31 +708,119 @@
return TRUE;
}
-#if 0
- // TODO: implement this
+ enum ExcludeFlags
+ {
+ excludeGIF = 0x01,
+ excludeBMP = 0x02,
+ excludeEMF = 0x04,
+ excludeWMF = 0x08,
+ excludeJPEG = 0x10,
+ excludePNG = 0x20,
+ excludeTIFF = 0x40,
+ excludeIcon = 0x80,
+ excludeOther = 0x80000000,
+ excludeDefaultLoad = 0,
+ excludeDefaultSave = excludeIcon | excludeEMF | excludeWMF
+ };
+
+ struct FILTER_DATA {
+ DWORD dwExclude;
+ const TCHAR *title;
+ const TCHAR *extensions;
+ const GUID *guid;
+ };
+
+protected:
+ static HRESULT GetCommonFilterString(
+ CSimpleString& strFilter,
+ CSimpleArray<GUID>& aguidFileTypes,
+ LPCTSTR pszAllFilesDescription,
+ DWORD dwExclude,
+ TCHAR chSeparator)
+ {
+ static const FILTER_DATA table[] =
+ {
+ {excludeBMP, TEXT("BMP"), TEXT("*.BMP;*.DIB;*.RLE"),
&Gdiplus::ImageFormatBMP},
+ {excludeJPEG, TEXT("JPEG"),
TEXT("*.JPG;*.JPEG;*.JPE;*.JFIF"), &Gdiplus::ImageFormatJPEG},
+ {excludeGIF, TEXT("GIF"), TEXT("*.GIF"),
&Gdiplus::ImageFormatGIF},
+ {excludeEMF, TEXT("EMF"), TEXT("*.EMF"),
&Gdiplus::ImageFormatEMF},
+ {excludeWMF, TEXT("WMF"), TEXT("*.WMF"),
&Gdiplus::ImageFormatWMF},
+ {excludeTIFF, TEXT("TIFF"), TEXT("*.TIF;*.TIFF"),
&Gdiplus::ImageFormatTIFF},
+ {excludePNG, TEXT("PNG"), TEXT("*.PNG"),
&Gdiplus::ImageFormatPNG},
+ {excludeIcon, TEXT("ICO"), TEXT("*.ICO"),
&Gdiplus::ImageFormatIcon}
+ };
+
+ if (pszAllFilesDescription)
+ {
+ strFilter += pszAllFilesDescription;
+ strFilter += chSeparator;
+
+ BOOL bFirst = TRUE;
+ for (size_t i = 0; i < _countof(table); ++i)
+ {
+ if ((dwExclude & table[i].dwExclude) != 0)
+ continue;
+
+ if (bFirst)
+ bFirst = FALSE;
+ else
+ strFilter += TEXT(';');
+
+ strFilter += table[i].extensions;
+ }
+ strFilter += chSeparator;
+
+ aguidFileTypes.Add(GUID_NULL);
+ }
+
+ for (size_t i = 0; i < _countof(table); ++i)
+ {
+ if ((dwExclude & table[i].dwExclude) != 0)
+ continue;
+ strFilter += table[i].title;
+ strFilter += TEXT(" (");
+ strFilter += table[i].extensions;
+ strFilter += TEXT(")");
+ strFilter += chSeparator;
+ strFilter += table[i].extensions;
+ strFilter += chSeparator;
+
+ aguidFileTypes.Add(*table[i].guid);
+ }
+
+ strFilter += chSeparator;
+
+ return S_OK;
+ }
+
+public:
static HRESULT GetImporterFilterString(
CSimpleString& strImporters,
CSimpleArray<GUID>& aguidFileTypes,
LPCTSTR pszAllFilesDescription = NULL,
DWORD dwExclude = excludeDefaultLoad,
- TCHAR chSeparator = _T('|'))
- {
- ATLASSERT(0);
- return -1;
- }
-
- // TODO: implement this
+ TCHAR chSeparator = TEXT('|'))
+ {
+ return GetCommonFilterString(strImporters,
+ aguidFileTypes,
+ pszAllFilesDescription,
+ dwExclude,
+ chSeparator);
+ }
+
static HRESULT GetExporterFilterString(
CSimpleString& strExporters,
CSimpleArray<GUID>& aguidFileTypes,
LPCTSTR pszAllFilesDescription = NULL,
DWORD dwExclude = excludeDefaultSave,
- TCHAR chSeparator = _T('|'))
- {
- ATLASSERT(0);
- return -1;
- }
-#endif // 0
+ TCHAR chSeparator = TEXT('|'))
+ {
+ return GetCommonFilterString(strExporters,
+ aguidFileTypes,
+ pszAllFilesDescription,
+ dwExclude,
+ chSeparator);
+ }
protected:
// an extension of BITMAPINFO