Engauge Digitizer  2
ImportImageExtensions.cpp
Go to the documentation of this file.
1 /******************************************************************************************************
2  * (C) 2018 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3  * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4  * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5  ******************************************************************************************************/
6 
8 #ifdef ENGAUGE_JPEG2000
9 #include "Jpeg2000.h"
10 #endif // ENGAUGE_JPEG2000
11 #include <QByteArray>
12 #include <QImageReader>
13 #include <QList>
14 
16 {
17 }
18 
20 {
21  // Compile a list of supported formats into a filter
22  QList<QByteArray>::const_iterator itr;
23  QList<QByteArray> supportedImageFormats = QImageReader::supportedImageFormats();
24  QStringList supportedImageFormatStrings;
25  for (itr = supportedImageFormats.begin (); itr != supportedImageFormats.end (); itr++) {
26  QByteArray arr = *itr;
27  QString extensionAsWildcard = QString ("*.%1").arg (QString (arr));
28  supportedImageFormatStrings << extensionAsWildcard;
29  }
30 #ifdef ENGAUGE_JPEG2000
31  Jpeg2000 jpeg2000;
32  supportedImageFormatStrings << jpeg2000.supportedImageWildcards();
33 #endif // ENGAUGE_JPEG2000
34 
35 #ifdef ENGAUGE_PDF
36  supportedImageFormatStrings << "*.pdf";
37 #endif // ENGAUGE_PDF
38 
39  supportedImageFormatStrings.sort();
40 
41  return supportedImageFormatStrings;
42 }
43 
44 bool ImportImageExtensions::offers (const QString &fileExtension) const
45 {
46  QString valueToTest = QString ("*.%1").arg (fileExtension.toLower());
47 
48  return fileExtensionsWithAsterisks().contains (valueToTest);
49 }
Wrapper around OpenJPEG library, in C, for opening jpeg2000 files.
Definition: Jpeg2000.h:26
QStringList supportedImageWildcards() const
List the supported jpeg2000 file extensions, for filtering import files.
Definition: Jpeg2000.cpp:305
bool offers(const QString &fileExtension) const
Return true if specified file extension is supported.
ImportImageExtensions()
Single constructor.
QStringList fileExtensionsWithAsterisks() const
File extensions for use in file dialogs.