20#include "kis_tiff_export.h"
22#include <tqcheckbox.h>
25#include <tdeapplication.h>
27#include <kdialogbase.h>
28#include <kgenericfactory.h>
30#include <KoFilterChain.h>
33#include <kis_group_layer.h>
35#include <kis_paint_layer.h>
36#include <kis_progress_display_interface.h>
38#include "kis_tiff_converter.h"
39#include "kis_dlg_options_tiff.h"
40#include "kis_wdg_options_tiff.h"
42typedef KGenericFactory<KisTIFFExport, KoFilter> KisTIFFExportFactory;
43K_EXPORT_COMPONENT_FACTORY(libchalktiffexport, KisTIFFExportFactory(
"kofficefilters"))
45KisTIFFExport::KisTIFFExport(KoFilter *, const
char *, const TQStringList&) : KoFilter()
49KisTIFFExport::~KisTIFFExport()
53KoFilter::ConversionStatus KisTIFFExport::convert(
const TQCString& from,
const TQCString& to)
55 kdDebug(41008) <<
"Tiff export! From: " << from <<
", To: " << to <<
"\n";
57 if (from !=
"application/x-chalk")
58 return KoFilter::NotImplemented;
63 KisDoc *output =
dynamic_cast<KisDoc*
>(m_chain->inputDocument());
65 KisColorSpace* cs = output->currentImage()->colorSpace();
66 KisChannelInfo::enumChannelValueType type = cs->channels()[0]->channelValueType();
67 if( type == KisChannelInfo::FLOAT16 || type == KisChannelInfo::FLOAT32)
69 kdb->optionswdg->kComboBoxPredictor->removeItem(1);
71 kdb->optionswdg->kComboBoxPredictor->removeItem(2);
74 if(kdb->exec() == TQDialog::Rejected)
79 KisTIFFOptions options = kdb->options();
81 if( ( type == KisChannelInfo::FLOAT16 || type == KisChannelInfo::FLOAT32) && options.predictor == 2 )
83 options.predictor = 3;
87 TQString filename = m_chain->outputFile();
90 return KoFilter::CreationError;
92 if (filename.isEmpty())
return KoFilter::FileNotFound;
95 url.setPath(filename);
101 img =
new KisImage(0, output->currentImage()->width(), output->currentImage()->height(), output->currentImage()->colorSpace(),
"");
102 KisPaintDeviceSP pd =
new KisPaintDevice(*output->currentImage()->projection());
103 KisPaintLayerSP l =
new KisPaintLayer(img,
"projection", OPACITY_OPAQUE, pd);
104 img->addLayer(l.data(), img->rootLayer(), 0);
106 img = output->currentImage();
110 KisTIFFConverter ktc(output, output->undoAdapter());
113 KisImageBuilder_Result res;
114 if ( (res = ktc.buildFile(url, img, options)) == KisImageBuilder_RESULT_OK) {
115 kdDebug(41008) <<
"success !" << endl;
118 kdDebug(41008) <<
" Result = " << res << endl;
119 return KoFilter::InternalError;
122#include <kis_tiff_export.moc>