1 /************************************************************************ 2 * * 3 * This file is part of Kooka, a scanning/OCR application using * 4 * Qt <http://www.qt.io> and KDE Frameworks <http://www.kde.org>. * 5 * * 6 * Copyright (C) 1999-2016 Klaas Freitag <freitag@suse.de> * 7 * Jonathan Marten <jjm@keelhaul.me.uk> * 8 * * 9 * Kooka is free software; you can redistribute it and/or modify it * 10 * under the terms of the GNU Library General Public License as * 11 * published by the Free Software Foundation and appearing in the * 12 * file COPYING included in the packaging of this file; either * 13 * version 2 of the License, or (at your option) any later version. * 14 * * 15 * As a special exception, permission is given to link this program * 16 * with any version of the KADMOS OCR/ICR engine (a product of * 17 * reRecognition GmbH, Kreuzlingen), and distribute the resulting * 18 * executable without including the source code for KADMOS in the * 19 * source distribution. * 20 * * 21 * This program is distributed in the hope that it will be useful, * 22 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 24 * GNU General Public License for more details. * 25 * * 26 * You should have received a copy of the GNU General Public * 27 * License along with this program; see the file COPYING. If * 28 * not, see <http://www.gnu.org/licenses/>. * 29 * * 30 ************************************************************************/ 31 32 #ifndef KOOKAIMAGE_H 33 #define KOOKAIMAGE_H 34 35 #include "kookacore_export.h" 36 37 #include <qimage.h> 38 #include <qurl.h> 39 40 class KFileItem; 41 42 43 /** 44 * @author Klaas Freitag 45 * 46 * class that represents an image, very much as QImage. But this one can contain 47 * multiple pages. 48 */ 49 50 // TODO: into class (but never used) 51 52 class KOOKACORE_EXPORT KookaImage : public QImage 53 { 54 public: 55 KookaImage(); 56 explicit KookaImage(const QImage &img); 57 ~KookaImage() = default; 58 59 KookaImage &operator=(const KookaImage &src); 60 61 /** 62 * load an image from a KURL. This method reads the entire file and sets 63 * the subimage count if applicable. Returns a null string if succeeded, 64 * or an error message string if failed. 65 */ 66 QString loadFromUrl(const QUrl &url); 67 68 /** 69 * The number of subimages. This is 0 if there are no subimages. 70 */ 71 int subImagesCount() const; 72 73 /** 74 * the parent image. 75 */ 76 KookaImage *parentImage() const; 77 78 /** 79 * returns true if this is a subimage. 80 */ 81 bool isSubImage() const; 82 83 /** 84 * Set and get the KFileItem of the image. Note that the KFileItem pointer returned 85 * may be nullptr. 86 */ 87 const KFileItem *fileItem() const; 88 void setFileItem(const KFileItem *item); 89 90 /** 91 * set the url of the kooka image. Note that loadFromUrl sets this 92 * url automatically. 93 */ 94 void setUrl(const QUrl &url); 95 QUrl url() const; 96 97 /** 98 * checks if the image is file bound ie. was loaded from file. If this 99 * method returns false, fileMetaInfo and FileItem are undefined. 100 */ 101 bool isFileBound() const; 102 103 104 private: 105 void init(); 106 QString loadTiffDir(const QString &file, int subno); 107 108 private: 109 int m_subImages; 110 QUrl m_url; 111 const KFileItem *m_fileItem; 112 bool m_fileBound; 113 }; 114 115 #endif // KOOKAIMAGE_H 116