filters
kis_tiff_export.cc00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "kis_tiff_export.h"
00021
00022 #include <qcheckbox.h>
00023 #include <qslider.h>
00024
00025 #include <kapplication.h>
00026 #include <kcombobox.h>
00027 #include <kdialogbase.h>
00028 #include <kgenericfactory.h>
00029
00030 #include <KoFilterChain.h>
00031
00032 #include <kis_doc.h>
00033 #include <kis_group_layer.h>
00034 #include <kis_image.h>
00035 #include <kis_paint_layer.h>
00036 #include <kis_progress_display_interface.h>
00037
00038 #include "kis_tiff_converter.h"
00039 #include "kis_dlg_options_tiff.h"
00040 #include "kis_wdg_options_tiff.h"
00041
00042 typedef KGenericFactory<KisTIFFExport, KoFilter> KisTIFFExportFactory;
00043 K_EXPORT_COMPONENT_FACTORY(libkritatiffexport, KisTIFFExportFactory("kofficefilters"))
00044
00045 KisTIFFExport::KisTIFFExport(KoFilter *, const char *, const QStringList&) : KoFilter()
00046 {
00047 }
00048
00049 KisTIFFExport::~KisTIFFExport()
00050 {
00051 }
00052
00053 KoFilter::ConversionStatus KisTIFFExport::convert(const QCString& from, const QCString& to)
00054 {
00055 kdDebug(41008) << "Tiff export! From: " << from << ", To: " << to << "\n";
00056
00057 if (from != "application/x-krita")
00058 return KoFilter::NotImplemented;
00059
00060
00061 KisDlgOptionsTIFF* kdb = new KisDlgOptionsTIFF(0, "options dialog for tiff");
00062
00063 KisDoc *output = dynamic_cast<KisDoc*>(m_chain->inputDocument());
00064
00065 KisColorSpace* cs = output->currentImage()->colorSpace();
00066 KisChannelInfo::enumChannelValueType type = cs->channels()[0]->channelValueType();
00067 if( type == KisChannelInfo::FLOAT16 || type == KisChannelInfo::FLOAT32)
00068 {
00069 kdb->optionswdg->kComboBoxPredictor->removeItem(1);
00070 } else {
00071 kdb->optionswdg->kComboBoxPredictor->removeItem(2);
00072 }
00073
00074 if(kdb->exec() == QDialog::Rejected)
00075 {
00076 return KoFilter::OK;
00077 }
00078
00079 KisTIFFOptions options = kdb->options();
00080
00081 if( ( type == KisChannelInfo::FLOAT16 || type == KisChannelInfo::FLOAT32) && options.predictor == 2 )
00082 {
00083 options.predictor = 3;
00084 }
00085 delete kdb;
00086
00087 QString filename = m_chain->outputFile();
00088
00089 if (!output)
00090 return KoFilter::CreationError;
00091
00092 if (filename.isEmpty()) return KoFilter::FileNotFound;
00093
00094 KURL url;
00095 url.setPath(filename);
00096
00097 KisImageSP img;
00098
00099 if(options.flatten)
00100 {
00101 img = new KisImage(0, output->currentImage()->width(), output->currentImage()->height(), output->currentImage()->colorSpace(), "");
00102 KisPaintDeviceSP pd = new KisPaintDevice(*output->currentImage()->projection());
00103 KisPaintLayerSP l = new KisPaintLayer(img, "projection", OPACITY_OPAQUE, pd);
00104 img->addLayer(l.data(), img->rootLayer(), 0);
00105 } else {
00106 img = output->currentImage();
00107 }
00108
00109
00110 KisTIFFConverter ktc(output, output->undoAdapter());
00111
00112
00113 KisImageBuilder_Result res;
00114 if ( (res = ktc.buildFile(url, img, options)) == KisImageBuilder_RESULT_OK) {
00115 kdDebug(41008) << "success !" << endl;
00116 return KoFilter::OK;
00117 }
00118 kdDebug(41008) << " Result = " << res << endl;
00119 return KoFilter::InternalError;
00120 }
00121
00122 #include <kis_tiff_export.moc>
00123
|