SilentEye 0.4.1

modules/seformatjpegold/seformatjpeg/seformatjpeg.cpp

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 #include "seformatjpeg.h"
00017 #include "imagejpeg.h"
00018 
00019 namespace SEFormatJPEG {
00020 
00021     SEFormatJpeg::SEFormatJpeg()
00022     {
00023         this->setObjectName("SEFormatJpeg");
00024         m_logger = new Logger(this);
00025 
00026         m_encodeWidget = new OptionWidget();
00027         m_encodeWidget->setObjectName("EncodeWidget");
00028         m_decodeWidget = new OptionWidget();
00029         m_decodeWidget->setObjectName("DecodeWidget");
00030 
00031         connect(m_encodeWidget, SIGNAL(optionHasChanged()), this, SLOT(optionHasChanged()));
00032     }
00033 
00034     SEFormatJpeg::~SEFormatJpeg()
00035     {
00036         delete(m_encodeWidget);
00037         delete(m_decodeWidget);
00038         delete m_logger;
00039     }
00040 
00041     QString SEFormatJpeg::name() const
00042     {
00043         return QString("Silent Eye Image Format JPEG");
00044     }
00045 
00046     QString SEFormatJpeg::version() const
00047     {
00048         return QString("1.0");
00049     }
00050 
00051     QString SEFormatJpeg::status() const
00052     {
00053         return "OK|";
00054     }
00055 
00056     QWidget* SEFormatJpeg::encodeWidget() const
00057     {
00058         return m_encodeWidget;
00059     }
00060 
00061     QWidget* SEFormatJpeg::decodeWidget() const
00062     {
00063         return m_decodeWidget;
00064     }
00065 
00066     QPointer<Image> SEFormatJpeg::encodeImage(QPointer<Image> img, bool dontDuplicate)
00067     {
00068         return updateImage(img, m_encodeWidget, dontDuplicate);
00069     }
00070 
00071     QPointer<Image> SEFormatJpeg::decodeImage(QPointer<Image> img, bool dontDuplicate)
00072     {
00073         return updateImage(img, m_decodeWidget, dontDuplicate);
00074     }
00075 
00076     QPointer<Image> SEFormatJpeg::updateImage(QPointer<Image> img, OptionWidget* w, bool dontDuplicate)
00077     {
00078         QPointer<Image> imgJpeg;
00079         if (dontDuplicate)
00080         {
00081             imgJpeg = new ImageJPEG(img); // don't copy image data
00082         }
00083         else
00084         {
00085             imgJpeg = new ImageJPEG(*img); // duplicate image into a new one
00086         }
00087 
00088         ImageJPEG* newImage = ((ImageJPEG*)imgJpeg.data());
00089         newImage->setK(w->k());
00090         newImage->setPassphrase(w->passphrase());
00091         newImage->setQuality(w->quality());
00092         newImage->setHeaderPosition(w->headerPosition());
00093 
00094         return newImage;
00095     }
00096 
00097     QString SEFormatJpeg::typeSupported() const
00098     {
00099         return QString("JPEG");
00100     }
00101 
00102     bool SEFormatJpeg::isEncodeWidgetReady() const
00103     {
00104         return true;
00105     }
00106 
00107     bool SEFormatJpeg::isDecodeWidgetReady() const
00108     {
00109         return true;
00110     }
00111 
00112     void SEFormatJpeg::optionHasChanged()
00113     {
00114         emit optionChanged();
00115     }
00116 
00117     Q_EXPORT_PLUGIN2(seformatjpeg, SEFormatJpeg)
00118 }