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 GROUPEDIMAGE_H_ 00017 #define GROUPEDIMAGE_H_ 00018 00019 #define PIXEL_GROUP_SIZE 8 00020 00021 #include <QObject> 00022 #include <QPointer> 00023 #include <QImage> 00024 #include <QVector> 00025 00026 #include <logger.h> 00027 #include "ycbcr.h" 00028 00029 using namespace SilentEyeFramework; 00030 00031 namespace SEFormatJPEG { 00032 00033 class PixelGroup : public QObject{ 00034 private: 00035 QPointer<Logger> m_logger; 00036 00037 QVector< QPointer<YCbCr> > m_pixels; 00038 float m_miv; 00039 00040 public: 00041 PixelGroup(QObject* parent=0); 00042 ~PixelGroup(); 00043 00044 QPointer<YCbCr> pixel(quint8, quint8); 00045 void setPixel(quint8, quint8, QPointer<YCbCr>); 00046 00047 float miv() const; 00048 void updateMivTo(float); 00049 00050 QString toString() const; 00051 00052 static quint8 width() { return PIXEL_GROUP_SIZE; } 00053 static quint8 height() { return PIXEL_GROUP_SIZE; } 00054 00055 private: 00056 void computeMIV(); 00057 void updatePixelMiv(QPointer<YCbCr>, double); 00058 }; 00059 00060 class GroupedImage : public QObject{ 00061 private: 00062 QPointer<Logger> m_logger; 00063 00064 quint16 m_width; 00065 quint16 m_height; 00066 quint16 m_initialWidth; 00067 quint16 m_initialHeight; 00068 QImage::Format m_initialFormat; 00069 00070 QVector< QPointer<PixelGroup> > m_pg; 00071 public: 00072 GroupedImage(QImage&, quint8, QObject* parent=0); 00073 ~GroupedImage(); 00074 00075 quint16 width(); 00076 quint16 height(); 00077 quint16 initialWidth(); 00078 quint16 initialHeight(); 00079 00080 QPointer<PixelGroup> pixelGroup(quint16, quint16); 00081 00082 QImage* toImage(); 00083 00084 private: 00085 void compacteAndGroupImage(QImage& image, quint8); 00086 00087 }; 00088 00089 } 00090 00091 #endif