1 /* 2 Drawpile - a collaborative drawing program. 3 4 Copyright (C) 2014-2019 Calle Laakkonen 5 6 Drawpile is free software: you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 Drawpile is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with Drawpile. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #ifndef IMAGESIZECHECK_H 21 #define IMAGESIZECHECK_H 22 23 class QSize; 24 class QImage; 25 class QColor; 26 27 #include "../libshared/net/message.h" 28 29 #include <QVector> 30 #include <QPair> 31 32 namespace utils { 33 34 //! Check if image dimensions are not too big. Returns true if size is OK 35 bool checkImageSize(const QSize &size); 36 37 /** 38 * @brief Check if we support writing an image file with this format 39 * 40 * The the format is identified from the filename suffix. 41 * Note that this function may return true even if the format is not found 42 * in the writableImageFormats list, since that list is restricted to just 43 * a reasonable set of commonly used formats. 44 * 45 * @param filename 46 * @return 47 */ 48 bool isWritableFormat(const QString &filename); 49 50 //! Get a whitelisted set of writable image formats 51 QVector<QPair<QString,QByteArray>> writableImageFormats(); 52 53 enum FileFormatOption { 54 Images = 0x01, 55 Recordings = 0x02, 56 AllFiles = 0x04, 57 Save = 0x08, 58 QtImagesOnly = 0x10, 59 60 OpenImages = Images | AllFiles, 61 OpenEverything = Images | Recordings | AllFiles, 62 SaveImages = Images | AllFiles | Save, 63 SaveRecordings = Recordings | AllFiles | Save 64 }; 65 Q_DECLARE_FLAGS(FileFormatOptions, FileFormatOption) 66 Q_DECLARE_OPERATORS_FOR_FLAGS(FileFormatOptions) 67 68 //! Get a filter string to use in an Open or Save dialog 69 QString fileFormatFilter(FileFormatOptions formats); 70 71 QColor isSolidColorImage(const QImage &image); 72 73 } 74 75 #endif 76 77