00001 /**************************************************************************** 00002 ** 00003 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 00004 ** Contact: Alexander Bokovoy <alexander.bokovoy@nokia.com> 00005 ** 00006 ** This file is part of the Quill Image Filters package. 00007 ** 00008 ** Commercial Usage 00009 ** Licensees holding valid Qt Commercial licenses may use this file in 00010 ** accordance with the Qt Commercial License Agreement provided with the 00011 ** Software or, alternatively, in accordance with the terms contained in 00012 ** a written agreement between you and Nokia. 00013 ** 00014 ** GNU Lesser General Public License Usage 00015 ** Alternatively, this file may be used under the terms of the GNU Lesser 00016 ** General Public License version 2.1 as published by the Free Software 00017 ** Foundation and appearing in the file LICENSE.LGPL included in the 00018 ** packaging of this file. Please review the following information to 00019 ** ensure the GNU Lesser General Public License version 2.1 requirements 00020 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 00021 ** 00022 ** In addition, as a special exception, Nokia gives you certain 00023 ** additional rights. These rights are described in the Nokia Qt LGPL 00024 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 00025 ** package. 00026 ** 00027 ** GNU General Public License Usage 00028 ** Alternatively, this file may be used under the terms of the GNU 00029 ** General Public License version 3.0 as published by the Free Software 00030 ** Foundation and appearing in the file LICENSE.GPL included in the 00031 ** packaging of this file. Please review the following information to 00032 ** ensure the GNU General Public License version 3.0 requirements will be 00033 ** met: http://www.gnu.org/copyleft/gpl.html. 00034 ** 00035 ** If you are unsure which license is appropriate for your use, please 00036 ** contact the sales department at qt-sales@nokia.com. 00037 ** 00038 ****************************************************************************/ 00039 00055 #ifndef __QUILL_FILTERS_LOAD_H__ 00056 #define __QUILL_FILTERS_LOAD_H__ 00057 00058 #include <QImageReader> 00059 #include <QBuffer> 00060 #include <QByteArray> 00061 #include <QCache> 00062 #include "quillimagefilter.h" 00063 #include "quillimagefilterimplementation.h" 00064 #include "readerstorage.h" 00065 00066 class QIODevice; 00067 class LoadFilterPrivate; 00068 class QuillImageFilterError; 00069 00070 class LoadFilter : public QuillImageFilterImplementation 00071 { 00072 public: 00073 LoadFilter(); 00074 ~LoadFilter(); 00075 00081 QuillImage apply(const QuillImage &tile) const; 00082 00087 QSize newFullImageSize(const QSize &fullImageSize) const; 00088 00089 bool setOption(const QString &option, const QVariant &value); 00090 QVariant option(const QString &option) const; 00091 const QStringList supportedOptions() const; 00092 00093 QIODevice* iODevice() const; 00094 void setIODevice(QIODevice* iODevice); 00095 QuillImageFilter::ImageFilterError error() const; 00096 00097 00098 virtual const QString name() const { return QuillImageFilter::Name_Load; } 00099 00100 QuillImageFilter::QuillFilterRole role() const; 00101 00102 private: 00103 void detectFormat(); 00104 void setError(QuillImageFilter::ImageFilterError error) const; 00105 QuillImageFilter::ImageFilterError translateReaderError 00106 (QImageReader::ImageReaderError errorCode) const; 00107 QImage readFromReader(QImageReader* reader) const; 00108 QByteArray formatFromReader(QImageReader *reader); 00109 00110 static QuillImage renderAlpha(const QuillImage &image, 00111 const QColor &backgroundColor); 00112 00113 int readOrientation() const; 00114 QRect rotateArea(const QSize &fullImageSize, const QRect &area,const QuillImage &tile) const; 00115 00116 private: 00117 LoadFilterPrivate *priv; 00118 static QImage fullImage; 00119 static ReaderStorage m_ReaderCache; 00120 00121 private: 00122 static const int Exif_Orientation_Normal = 1; 00123 static const int Exif_Orientation_Rotated90 = 6; 00124 static const int Exif_Orientation_Rotated180 = 3; 00125 static const int Exif_Orientation_Rotated270 = 8; 00126 }; 00127 00128 #endif // __QUILL_FILTERS_LOAD_H__