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 <kdialogbase.h>
00027 #include <kgenericfactory.h>
00028
00029 #include <KoFilterChain.h>
00030
00031 #include <kis_doc.h>
00032 #include <kis_group_layer.h>
00033 #include <kis_image.h>
00034 #include <kis_paint_layer.h>
00035 #include <kis_progress_display_interface.h>
00036
00037 #include "kis_tiff_converter.h"
00038 #include "kis_dlg_options_tiff.h"
00039 #include "kis_wdg_options_tiff.h"
00040
00041 typedef KGenericFactory<KisTIFFExport, KoFilter> KisTIFFExportFactory;
00042 K_EXPORT_COMPONENT_FACTORY(libkritatiffexport, KisTIFFExportFactory("kofficefilters"))
00043
00044 KisTIFFExport::KisTIFFExport(KoFilter *, const char *, const QStringList&) : KoFilter()
00045 {
00046 }
00047
00048 KisTIFFExport::~KisTIFFExport()
00049 {
00050 }
00051
00052 KoFilter::ConversionStatus KisTIFFExport::convert(const QCString& from, const QCString& to)
00053 {
00054 kdDebug(41008) << "Tiff export! From: " << from << ", To: " << to << "\n";
00055
00056 if (from != "application/x-krita")
00057 return KoFilter::NotImplemented;
00058
00059
00060 KisDlgOptionsTIFF* kdb = new KisDlgOptionsTIFF(0, "options dialog for tiff");
00061
00062 if(kdb->exec() == QDialog::Rejected)
00063 {
00064 return KoFilter::OK;
00065 }
00066
00067 KisTIFFOptions options = kdb->options();
00068
00069 delete kdb;
00070
00071 KisDoc *output = dynamic_cast<KisDoc*>(m_chain->inputDocument());
00072 QString filename = m_chain->outputFile();
00073
00074 if (!output)
00075 return KoFilter::CreationError;
00076
00077 if (filename.isEmpty()) return KoFilter::FileNotFound;
00078
00079 KURL url;
00080 url.setPath(filename);
00081
00082 KisImageSP img;
00083
00084 if(options.flatten)
00085 {
00086 img = new KisImage(0, output->currentImage()->width(), output->currentImage()->height(), output->currentImage()->colorSpace(), "");
00087 KisPaintDeviceSP pd = new KisPaintDevice(*output->currentImage()->projection());
00088 KisPaintLayerSP l = new KisPaintLayer(img, "projection", OPACITY_OPAQUE, pd);
00089 img->addLayer(l.data(), img->rootLayer(), 0);
00090 } else {
00091 img = output->currentImage();
00092 }
00093
00094
00095 KisTIFFConverter ktc(output, output->undoAdapter());
00096
00097
00098 KisImageBuilder_Result res;
00099 if ( (res = ktc.buildFile(url, img, options)) == KisImageBuilder_RESULT_OK) {
00100 kdDebug(41008) << "success !" << endl;
00101 return KoFilter::OK;
00102 }
00103 kdDebug(41008) << " Result = " << res << endl;
00104 return KoFilter::InternalError;
00105 }
00106
00107 #include <kis_tiff_export.moc>
00108
|