SilentEye 0.4.1

modules/seformatjpegold/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 
00029     class ImageJPEG : public Image
00030     {
00031     public:
00032         enum HeaderPosition{TOP=1, BOTTOM=2, SIGNATURE=3};
00033 
00034     private:
00035         QPointer<Logger> m_logger;
00036 
00037         quint16 m_nbBits;
00038         int m_k;
00039         QString m_passphrase;
00040         int m_quality;
00041         HeaderPosition m_headerPosition;
00042         int m_blockWidth;
00043         int m_blockHeight;
00044         int m_blockInnerPos;
00045 
00046     public:
00047         ImageJPEG();
00048         ~ImageJPEG();
00049         ImageJPEG(const QString& filePath);
00050         ImageJPEG(const QPixmap& pixmap, QString filePath="Pixmap");
00051         ImageJPEG(const Image& image);
00052         ImageJPEG(Image* image);
00053 
00054         void setK(int);
00055         void setPassphrase(QString);
00056         void setQuality(int);
00057         void setHeaderPosition(HeaderPosition);
00058 
00059         quint32 capacity() const;
00060 
00061         bool loadData();
00062         bool hideData();
00063         bool saveToDir(QString& outputDirPath);
00064 
00065     private:
00066         void init();
00067         int computeDistributionStep(quint32 size, int width, int height);
00068         QPoint* computeHeaderPosition(int width, int height);
00069         bool isBetweenPoint(const QPoint&, const QPoint&, const QPoint&);
00070         QPoint computeNewPosition(const QPoint&, int, int width, int height, bool=false);
00071     };
00072 }
00073 #endif