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