SilentEye 0.4.1
|
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 IMAGEBMP_H_ 00017 #define IMAGEBMP_H_ 00018 00019 #define EQUI_NB_STEP_MIN 9 00020 00021 #include <QPointer> 00022 #include <image.h> 00023 #include <logger.h> 00024 00025 using namespace SilentEyeFramework; 00026 00027 namespace SEFormatBMP { 00028 00029 class ImageBMP : public Image 00030 { 00031 public: 00032 enum HeaderPosition{TOP=1, BOTTOM=2, SIGNATURE=3}; 00033 enum DataDistribution{INLINE=1, EQUI=2}; 00034 00035 private: 00036 QPointer<Logger> m_logger; 00037 00038 QImage m_img; 00039 unsigned short int m_nbBits; 00040 bool m_useRed; 00041 bool m_useGreen; 00042 bool m_useBlue; 00043 int m_nbColorUsed; 00044 HeaderPosition m_headerPosition; 00045 DataDistribution m_distribution; 00046 unsigned short int m_swap; 00047 int m_blockWidth; 00048 int m_blockHeight; 00049 int m_blockInnerPos; 00050 00051 public: 00052 ImageBMP(); 00053 ~ImageBMP(); 00054 ImageBMP(const QString& filePath); 00055 ImageBMP(const QPixmap& pixmap, QString filePath="Pixmap"); 00056 ImageBMP(const Image& image); 00057 ImageBMP(Image* image); 00058 00059 unsigned short int nbBits() const; 00060 bool setNbBits(const unsigned short int nb); 00061 void setColorUsed(bool r=true, bool g=true, bool b=true); 00062 void setDistribution(DataDistribution); 00063 void setHeaderPosition(HeaderPosition); 00064 00065 quint32 capacity() const; 00066 00067 bool loadData(); 00068 bool saveToDir(QString& outputDirPath); 00069 00070 private: 00071 bool hideData(); 00072 int changeColor(int color, const int val); 00073 int computeDistributionStep(quint32 size); 00074 QPoint* computeHeaderPosition(); 00075 bool isBetweenPoint(const QPoint&, const QPoint&, const QPoint&); 00076 QPoint computeNewPosition(const QPoint&, int, bool=false); 00077 00078 }; 00079 } 00080 00081 #endif 00082