Partager via


CImage::GetImporterFilterString

Finds image formats available for loading images.

static HRESULT GetImporterFilterString( 
   CSimpleString& strImporters, 
   CSimpleArray< GUID >& aguidFileTypes, 
   LPCTSTR pszAllFilesDescription = NULL, 
   DWORD dwExclude = excludeDefaultLoad, 
   TCHAR chSeparator = _T( '|' ) 
);

Parameters

  • strImporters
    A reference to a CSimpleString object. See Remarks for more information.

  • aguidFileTypes
    An array of GUIDs, with each element corresponding to one of the file types in the string. In the example in pszAllFilesDescription below, aguidFileTypes[0] is GUID_NULL with the remaining array values are the image file formats supported by the current operating system.

    Note

    For a complete list of constants, see Image File Format Constants in the Windows SDK.

  • pszAllFilesDescription
    If this parameter is not NULL, the filter string will have one additional filter at the beginning of the list. This filter will have the current value of pszAllFilesDescription for its description, and accepts files of any extension supported by any other exporter in the list.

    For example:

    //First filter in the list will be titled "All Image Files", and
    //will accept files with any extension supported by any importer.
    CImage::GetImporterFilterString( strImporters, aguidFileTypes, 
       _T("All Image Files"));
    
  • dwExclude
    Set of bit flags specifying which file types to exclude from the list. Allowable flags are:

    • excludeGIF = 0x01   Excludes GIF files.

    • excludeBMP = 0x02   Excludes BMP (Windows Bitmap) files.

    • excludeEMF = 0x04   Excludes EMF (Enhanced Metafile) files.

    • excludeWMF = 0x08   Excludes WMF (Windows Metafile) files.

    • excludeJPEG = 0x10   Excludes JPEG files.

    • excludePNG = 0x20   Excludes PNG files.

    • excludeTIFF = 0x40   Excludes TIFF files.

    • excludeIcon = 0x80   Excludes ICO (Windows Icon) files.

    • excludeOther = 0x80000000   Excludes any other file type not listed above.

    • excludeDefaultLoad = 0   For load, all file types are included by default

    • excludeDefaultSave = excludeIcon | excludeEMF | excludeWMF   For saving, these files are excluded by default because they usually have special requirements.

  • chSeparator
    The separator used between the image formats. See Remarks for more information.

Remarks

You can pass the resulting format string to your MFC CFileDialog object to expose the file extensions of the available image formats in the File Open dialog box.

The parameter strImporter has the format:

file description0|*.ext0|filedescription1|*.ext1|...file descriptionn|*.extn||

where '|' is the separator character specified by chSeparator. For example:

"Bitmap format|*.bmp|JPEG format|*.jpg|GIF format|*.gif|PNG format|*.png||"

Use the default separator '|' if you pass this string to an MFC CFileDialog object. Use the null separator '\0' if you pass this string to a common File Open dialog box.

Requirements

Header: atlimage.h

See Also

Reference

CImage Class

CImage::GetExporterFilterString

CFileDialog::m_ofn

CFileDialog::GetFileExt

OPENFILENAME

CFileDialog::SetDefExt