filters
kis_png_export.cc00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "kis_png_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_image.h>
00033 #include <kis_paint_layer.h>
00034 #include <kis_progress_display_interface.h>
00035
00036 #include "kis_png_converter.h"
00037 #include "kis_wdg_options_png.h"
00038
00039 typedef KGenericFactory<KisPNGExport, KoFilter> KisPNGExportFactory;
00040 K_EXPORT_COMPONENT_FACTORY(libkritapngexport, KisPNGExportFactory("kofficefilters"))
00041
00042 KisPNGExport::KisPNGExport(KoFilter *, const char *, const QStringList&) : KoFilter()
00043 {
00044 }
00045
00046 KisPNGExport::~KisPNGExport()
00047 {
00048 }
00049
00050 KoFilter::ConversionStatus KisPNGExport::convert(const QCString& from, const QCString& to)
00051 {
00052 kdDebug(41008) << "Png export! From: " << from << ", To: " << to << "\n";
00053
00054 if (from != "application/x-krita")
00055 return KoFilter::NotImplemented;
00056
00057
00058 KDialogBase* kdb = new KDialogBase(0, "", false, i18n("PNG Export Options"), KDialogBase::Ok | KDialogBase::Cancel);
00059
00060 KisWdgOptionsPNG* wdg = new KisWdgOptionsPNG(kdb);
00061 kdb->setMainWidget(wdg);
00062 kapp->restoreOverrideCursor();
00063 if(kdb->exec() == QDialog::Rejected)
00064 {
00065 return KoFilter::OK;
00066 }
00067
00068 bool alpha = wdg->alpha->isChecked();
00069 bool interlace = wdg->interlacing->isChecked();
00070 int compression = wdg->compressionLevel->value();
00071
00072 delete kdb;
00073
00074 KisDoc *output = dynamic_cast<KisDoc*>(m_chain->inputDocument());
00075 QString filename = m_chain->outputFile();
00076
00077 if (!output)
00078 return KoFilter::CreationError;
00079
00080
00081 if (filename.isEmpty()) return KoFilter::FileNotFound;
00082
00083 KURL url;
00084 url.setPath(filename);
00085
00086 KisImageSP img = output->currentImage();
00087
00088 KisPNGConverter kpc(output, output->undoAdapter());
00089
00090 vKisAnnotationSP_it beginIt = img->beginAnnotations();
00091 vKisAnnotationSP_it endIt = img->endAnnotations();
00092 KisImageBuilder_Result res;
00093
00094 KisPaintDeviceSP pd = new KisPaintDevice(*img->projection());
00095 KisPaintLayerSP l = new KisPaintLayer(img, "projection", OPACITY_OPAQUE, pd);
00096
00097 if ( (res = kpc.buildFile(url, l, beginIt, endIt, compression, interlace, alpha)) == KisImageBuilder_RESULT_OK) {
00098 kdDebug(41008) << "success !" << endl;
00099 return KoFilter::OK;
00100 }
00101 kdDebug(41008) << " Result = " << res << endl;
00102 return KoFilter::InternalError;
00103 }
00104
00105 #include <kis_png_export.moc>
00106
|