SilentEye 0.4.1

modules/seformatjpeg/imagejpeg.h

Go to the documentation of this file.
00001 //  This file is part of SilentEye.
00002 //
00003 //  SilentEye is free software: you can redistribute it and/or modify
00004 //  it under the terms of the GNU General Public License as published by
00005 //  the Free Software Foundation, either version 3 of the License, or
00006 //  (at your option) any later version.
00007 //
00008 //  SilentEye is distributed in the hope that it will be useful,
00009 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 //  GNU General Public License for more details.
00012 //
00013 //  You should have received a copy of the GNU General Public License
00014 //  along with SilentEye.  If not, see <http://www.gnu.org/licenses/>.
00015 
00016 #ifndef IMAGEJPEG_H_
00017 #define IMAGEJPEG_H_
00018 
00019 #include <image.h>
00020 #include <encodeddata.h>
00021 #include <QDebug>
00022 
00023 #define EQUI_NB_STEP_MIN 9
00024 
00025 using namespace SilentEyeFramework;
00026 
00027 namespace SEFormatJPEG {
00028 
00030     class ImageJPEG : public Image
00031     {
00032     public:
00033         enum HeaderPosition{TOP=1 , 
00034             BOTTOM=2 , 
00035             SIGNATURE=3 };
00036 
00037     private:
00039         QPointer<Logger> m_logger;
00040 
00042         quint16 m_nbBits;
00044         int m_k;
00046         QString m_passphrase;
00048         int m_quality;
00050         HeaderPosition m_headerPosition;
00052         int m_blockWidth;
00054         int m_blockHeight;
00056         int m_blockInnerPos;
00057 
00058     public:
00060         ImageJPEG();
00061         ~ImageJPEG();
00063         ImageJPEG(const QString& filePath);
00065         ImageJPEG(const QPixmap& pixmap, QString filePath="Pixmap");
00067         ImageJPEG(const Image& image);
00069         ImageJPEG(Image* image);
00070 
00071         void setK(int);
00072         void setPassphrase(QString);
00073         void setQuality(int);
00074         void setHeaderPosition(HeaderPosition);
00075 
00077         quint32 capacity() const;
00078 
00080         bool loadData();
00082 
00085         bool saveToDir(QString&);
00086 
00087     private:
00088         void init();
00090 
00095         int computeDistributionStep(quint32, int, int);
00096         
00098 
00102         QPoint* computeHeaderPosition(int, int);
00103         
00105 
00110         bool isBetweenPoint(const QPoint&, const QPoint&, const QPoint&);
00111         
00113 
00120         QPoint computeNewPosition(const QPoint&, int, int width, int height, bool=false);
00121     };
00122 }
00123 #endif