diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-26 00:41:16 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-26 00:41:16 +0000 |
commit | 698569f8428ca088f764d704034a1330517b98c0 (patch) | |
tree | bf45be6946ebbbee9cce5a5bcf838f4c952d87e6 /chalk/plugins/viewplugins/separate_channels | |
parent | 2785103a6bd4de55bd26d79e34d0fdd4b329a73a (diff) | |
download | koffice-698569f8428ca088f764d704034a1330517b98c0.tar.gz koffice-698569f8428ca088f764d704034a1330517b98c0.zip |
Finish rebranding of Krita as Chalk
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1238363 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'chalk/plugins/viewplugins/separate_channels')
10 files changed, 951 insertions, 0 deletions
diff --git a/chalk/plugins/viewplugins/separate_channels/Makefile.am b/chalk/plugins/viewplugins/separate_channels/Makefile.am new file mode 100644 index 00000000..9b28a89d --- /dev/null +++ b/chalk/plugins/viewplugins/separate_channels/Makefile.am @@ -0,0 +1,27 @@ +chalkrcdir = $(kde_datadir)/chalkplugins +chalkrc_DATA = imageseparate.rc +EXTRA_DIST = $(chalkrc_DATA) + +INCLUDES = -I$(srcdir)/../../../sdk \ + -I$(srcdir)/../../../core \ + -I$(srcdir)/../../../chalkcolor/ \ + -I$(srcdir)/../../../ui \ + $(KOFFICE_INCLUDES) \ + $(all_includes) + +kde_module_LTLIBRARIES = chalkseparatechannels.la + +chalkseparatechannels_la_SOURCES = wdg_separations.ui \ + kis_channel_separator.cc dlg_separate.cc \ + kis_separate_channels_plugin.cc + +noinst_HEADERS = wdg_separations.h kis_separate_channels_plugin.h \ + kis_channel_separator.h dlg_separate.h + +kde_services_DATA = chalkseparatechannels.desktop + +chalkseparatechannels_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) $(LIB_QT) -lkdecore -lkdeui -lkjs -lkdefx -lkio -lkparts -L../../../../chalk/chalkcolor/.libs -lchalkcolor -L../../../../chalk/core/.libs -lchalkimage \ + -L../../../../chalk/ui/.libs -lchalkui -L../../../../lib/kofficeui/.libs -lkofficeui -L../../../../lib/kofficecore/.libs -lkofficecore +chalkseparatechannels_la_LIBADD = ../../../libchalkcommon.la + +chalkseparatechannels_la_METASOURCES = AUTO diff --git a/chalk/plugins/viewplugins/separate_channels/chalkseparatechannels.desktop b/chalk/plugins/viewplugins/separate_channels/chalkseparatechannels.desktop new file mode 100644 index 00000000..efb596b8 --- /dev/null +++ b/chalk/plugins/viewplugins/separate_channels/chalkseparatechannels.desktop @@ -0,0 +1,42 @@ +[Desktop Entry] +Name=Separate Channels Plugin +Name[bg]=Приставка за отделен канал +Name[ca]=Connector de canals separats +Name[da]=Plugin for separate kanaler +Name[de]="Kanäle trennen"-Modul +Name[el]=Πρόσθετο διαχωρισμού καναλιών +Name[eo]=Apartkanal-kromaĵo +Name[es]=Complemento para canales separados +Name[et]=Kanalite lahutamise plugin +Name[fa]=جدا کردن وصلۀ مجراها +Name[fr]=Module de séparation des canaux +Name[fy]=Plugin foar aparte kanalen +Name[gl]=Plugin de Separación de Canais +Name[he]=תוסף לריבוי ערוצים +Name[hu]=Csatornaszétválasztó modul +Name[is]=Aðgreindar rásir íforrit +Name[it]=Plugin per la separazione dei canali +Name[ja]=チャンネル分離プラグイン +Name[km]=កម្មវិធីជំនួយដើម្បីបំបែកឆានែល +Name[nb]=Programtillegg for atskilte kanaler +Name[nds]=Kanaaltrenn-Moduul +Name[ne]=च्यानल प्लगइन छुट्याउनुहोस् +Name[nl]=Plugin voor aparte kanalen +Name[pl]=Wtyczka oddzielania kanałów +Name[pt]='Plugin' de Separação de Canais +Name[pt_BR]=Plugin de Separação de Canais +Name[ru]=Разбор изображения по каналам +Name[sk]=Modul oddelenie kanálov +Name[sl]=Vstavek za ločevanje kanalov +Name[sr]=Прикључак за раздвајање канала +Name[sr@Latn]=Priključak za razdvajanje kanala +Name[sv]=Insticksprogram för separata kanaler +Name[uk]=Втулок розділення каналів +Name[uz]=Kanallarni ajratish uchun plagin +Name[uz@cyrillic]=Каналларни ажратиш учун плагин +Name[zh_CN]=独立通道插件 +Name[zh_TW]=分離色頻外掛程式 +ServiceTypes=Chalk/ViewPlugin +Type=Service +X-KDE-Library=chalkseparatechannels +X-Chalk-Version=2 diff --git a/chalk/plugins/viewplugins/separate_channels/dlg_separate.cc b/chalk/plugins/viewplugins/separate_channels/dlg_separate.cc new file mode 100644 index 00000000..e6124046 --- /dev/null +++ b/chalk/plugins/viewplugins/separate_channels/dlg_separate.cc @@ -0,0 +1,110 @@ +/* + * dlg_separate.cc - part of KimageShop^WKrayon^WChalk + * + * Copyright (c) 2004 Boudewijn Rempt <boud@valdyas.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include <tqradiobutton.h> +#include <tqcheckbox.h> +#include <tqbuttongroup.h> +#include <tqlabel.h> +#include <tqcombobox.h> +#include <tqbutton.h> + +#include <klocale.h> +#include <knuminput.h> +#include <kdebug.h> + +#include "dlg_separate.h" +#include "wdg_separations.h" + +DlgSeparate::DlgSeparate( const TQString & imageCS, + const TQString & layerCS, + TQWidget * tqparent, + const char * name) + : super (tqparent, name, true, i18n("Separate Image"), Ok | Cancel, Ok), + m_imageCS(imageCS), + m_layerCS(layerCS) +{ + m_page = new WdgSeparations(this, "separate_image"); + Q_CHECK_PTR(m_page); + setMainWidget(m_page); + resize(m_page->tqsizeHint()); + + m_page->lblColormodel->setText(layerCS); + m_page->grpOutput->hide(); + connect(m_page->grpSource, TQT_SIGNAL(clicked(int)), this, TQT_SLOT(slotSetColorSpaceLabel(int))); + connect(m_page->chkColors, TQT_SIGNAL(toggled(bool)), m_page->chkDownscale, TQT_SLOT(setDisabled(bool))); + + connect(this, TQT_SIGNAL(okClicked()), + this, TQT_SLOT(okClicked())); +} + +DlgSeparate::~DlgSeparate() +{ + delete m_page; +} + + + +enumSepAlphaOptions DlgSeparate::getAlphaOptions() +{ + return (enumSepAlphaOptions)m_page->grpAlpha->selectedId(); +} + +enumSepSource DlgSeparate::getSource() +{ + return (enumSepSource)m_page->grpSource->selectedId(); +} + +enumSepOutput DlgSeparate::getOutput() +{ + return (enumSepOutput)m_page->grpOutput->selectedId(); +} + + +bool DlgSeparate::getDownscale() +{ + return m_page->chkDownscale->isChecked(); +} + +bool DlgSeparate::getToColor() +{ + return m_page->chkColors->isChecked(); +} + +// SLOTS + +void DlgSeparate::okClicked() +{ + accept(); +} + +void DlgSeparate::slotSetColorSpaceLabel(int buttonid) +{ + if (buttonid == 0) { + m_page->lblColormodel->setText(m_layerCS); + } + else { + m_page->lblColormodel->setText(m_imageCS); + } +} +void DlgSeparate::enableDownscale(bool enable) { + m_page->chkDownscale->setEnabled(enable); +} + +#include "dlg_separate.moc" diff --git a/chalk/plugins/viewplugins/separate_channels/dlg_separate.h b/chalk/plugins/viewplugins/separate_channels/dlg_separate.h new file mode 100644 index 00000000..d3536dda --- /dev/null +++ b/chalk/plugins/viewplugins/separate_channels/dlg_separate.h @@ -0,0 +1,68 @@ +/* + * dlg_imagesize.h -- part of KimageShop^WKrayon^WChalk + * + * Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#ifndef DLG_SEPARATE +#define DLG_SEPARATE + +#include <kdialogbase.h> +#include <kis_channel_separator.h> + +class WdgSeparations; + +/** + * This dialog allows the user to configure the decomposition of an image + * into layers: one layer for each color channel. + */ +class DlgSeparate: public KDialogBase { + typedef KDialogBase super; + Q_OBJECT + TQ_OBJECT + +public: + + DlgSeparate(const TQString & imageCS, const TQString & layerCS, TQWidget * tqparent = 0, + const char* name = 0); + ~DlgSeparate(); + +public: + + enumSepAlphaOptions getAlphaOptions(); + enumSepSource getSource(); + enumSepOutput getOutput(); + + bool getDownscale(); + void enableDownscale(bool enable); + + bool getToColor(); + + +private slots: + + void slotSetColorSpaceLabel(int buttonid); + void okClicked(); + +private: + + WdgSeparations * m_page; + TQString m_imageCS; + TQString m_layerCS; + +}; + +#endif // DLG_SEPARATE diff --git a/chalk/plugins/viewplugins/separate_channels/imageseparate.rc b/chalk/plugins/viewplugins/separate_channels/imageseparate.rc new file mode 100644 index 00000000..b0518510 --- /dev/null +++ b/chalk/plugins/viewplugins/separate_channels/imageseparate.rc @@ -0,0 +1,9 @@ +<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> +<kpartgui library="chalkseparatechannels" version="6"> +<MenuBar> + <Menu name="Image"><text>Image</text> + <Separator/> + <Action name="separate"/> + </Menu> +</MenuBar> +</kpartgui> diff --git a/chalk/plugins/viewplugins/separate_channels/kis_channel_separator.cc b/chalk/plugins/viewplugins/separate_channels/kis_channel_separator.cc new file mode 100644 index 00000000..3315177c --- /dev/null +++ b/chalk/plugins/viewplugins/separate_channels/kis_channel_separator.cc @@ -0,0 +1,301 @@ +/* + * This file is part of Chalk + * + * Copyright (c) 2005 Michael Thaler <michael.thaler@physik.tu-muenchen.de> + * + * ported from Gimp, Copyright (C) 1997 Eiichi Takamori <taka@ma1.seikyou.ne.jp> + * original pixelize.c for GIMP 0.54 by Tracy Scott + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include <limits.h> + +#include <stdlib.h> +#include <vector> + +#include <klocale.h> +#include <kiconloader.h> +#include <kinstance.h> +#include <kmessagebox.h> +#include <kstandarddirs.h> +#include <ktempfile.h> +#include <kdebug.h> +#include <kgenericfactory.h> +#include <knuminput.h> +#include <kfiledialog.h> + + +#include <KoFilterManager.h> + +#include <kis_doc.h> +#include <kis_image.h> +#include "kis_meta_registry.h" +#include <kis_iterators_pixel.h> +#include <kis_layer.h> +#include <kis_paint_layer.h> +#include <kis_group_layer.h> +#include <kis_transaction.h> +#include <kis_undo_adapter.h> +#include <kis_global.h> +#include <kis_types.h> +#include <kis_progress_subject.h> +#include <kis_progress_display_interface.h> +#include <kis_colorspace.h> +#include <kis_colorspace_factory_registry.h> +#include <kis_view.h> +#include <kis_paint_device.h> +#include <kis_channelinfo.h> + +#include "kis_channel_separator.h" + +KisChannelSeparator::KisChannelSeparator(KisView * view) + : m_view(view) +{ +} + +void KisChannelSeparator::separate(KisProgressDisplayInterface * progress, enumSepAlphaOptions alphaOps, enumSepSource sourceOps, enumSepOutput outputOps, bool downscale, bool toColor) +{ + KisImageSP image = m_view->canvasSubject()->currentImg(); + if (!image) return; + + KisLayerSP layer = image->activeLayer(); + if (!layer) return; + + KisPaintDeviceSP src = image->activeDevice(); + if (!src) return; + + m_cancelRequested = false; + if ( progress ) + progress->setSubject(this, true, true); + emit notifyProgressStage(i18n("Separating image..."), 0); + + KisColorSpace * dstCs = 0; + + TQ_UINT32 numberOfChannels = src->nChannels(); + KisColorSpace * srcCs = src->colorSpace(); + TQValueVector<KisChannelInfo *> channels = srcCs->channels(); + + // Use the flattened image, if required + switch(sourceOps) { + + case(ALL_LAYERS): + src = image->mergedImage(); + break; + default: + break; + } + + vKisPaintDeviceSP layers; + + TQValueVector<KisChannelInfo *>::const_iterator begin = channels.begin(); + TQValueVector<KisChannelInfo *>::const_iterator end = channels.end(); + + + TQRect rect = src->exactBounds(); + + int i = 0; + TQ_UINT32 channelIndex = 0; + for (TQValueVector<KisChannelInfo *>::const_iterator it = begin; it != end; ++it, ++channelIndex) + { + + KisChannelInfo * ch = (*it); + + if (ch->channelType() == KisChannelInfo::ALPHA && alphaOps != CREATE_ALPHA_SEPARATION) { + continue; + } + + TQ_INT32 channelSize = ch->size(); + TQ_INT32 channelPos = ch->pos(); + TQ_INT32 destSize = 1; + + KisPaintDeviceSP dev; + if (toColor) { + // We don't downscale if we separate to color channels + dev = new KisPaintDevice(srcCs, "color separations"); + } + else { + if (channelSize == 1 || downscale) { + dev = new KisPaintDevice( KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("GRAYA",""),"" ), "8 bit grayscale sep"); + } + else { + dev = new KisPaintDevice( KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("GRAYA16",""),"" ), "16 bit grayscale sep"); + destSize = 2; + } + } + + dstCs = dev->colorSpace(); + + layers.push_back(dev); + + for (TQ_INT32 row = 0; row < rect.height(); ++row) { + + KisHLineIteratorPixel srcIt = src->createHLineIterator(rect.x(), rect.y() + row, rect.width(), false); + KisHLineIteratorPixel dstIt = dev->createHLineIterator(rect.x(), rect.y() + row, rect.width(), true); + + while( ! srcIt.isDone() ) + { + if (srcIt.isSelected()) + { + if (toColor) { + dstCs->getSingleChannelPixel(dstIt.rawData(), srcIt.rawData(), channelIndex); + + if (alphaOps == COPY_ALPHA_TO_SEPARATIONS) { + //dstCs->setAlpha(dstIt.rawData(), srcIt.rawData()[srcAlphaPos], 1); + dstCs->setAlpha(dstIt.rawData(), srcCs->getAlpha(srcIt.rawData()), 1); + } + else { + dstCs->setAlpha(dstIt.rawData(), OPACITY_OPAQUE, 1); + } + } + else { + + // To grayscale + + // Decide wether we need downscaling + if (channelSize == 1 && destSize == 1) { + + // Both 8-bit channels + dstIt.rawData()[0] = srcIt.rawData()[channelPos]; + + if (alphaOps == COPY_ALPHA_TO_SEPARATIONS) { + dstCs->setAlpha(dstIt.rawData(), srcCs->getAlpha(srcIt.rawData()), 1); + } + else { + dstCs->setAlpha(dstIt.rawData(), OPACITY_OPAQUE, 1); + } + } + else if (channelSize == 2 && destSize == 2) { + + // Both 16-bit + dstIt.rawData()[0] = srcIt.rawData()[channelPos]; + dstIt.rawData()[1] = srcIt.rawData()[channelPos + 1]; + + if (alphaOps == COPY_ALPHA_TO_SEPARATIONS) { + dstCs->setAlpha(dstIt.rawData(), srcCs->getAlpha(srcIt.rawData()), 1); + } + else { + dstCs->setAlpha(dstIt.rawData(), OPACITY_OPAQUE, 1); + } + } + else if (channelSize != 1 && destSize == 1) { + // Downscale + memset(dstIt.rawData(), srcCs->scaleToU8(srcIt.rawData(), channelPos), 1); + + // XXX: Do alpha + dstCs->setAlpha(dstIt.rawData(), OPACITY_OPAQUE, 1); + } + else if (channelSize != 2 && destSize == 2) { + // Upscale + dstIt.rawData()[0] = srcCs->scaleToU8(srcIt.rawData(), channelPos); + + // XXX: Do alpha + dstCs->setAlpha(dstIt.rawData(), OPACITY_OPAQUE, 1); + + } + } + } + ++dstIt; + ++srcIt; + } + } + ++i; + + emit notifyProgress((i * 100) / numberOfChannels); + if (m_cancelRequested) { + break; + } + } + + vKisPaintDeviceSP_it deviceIt = layers.begin(); + + emit notifyProgressDone(); + + if (!m_cancelRequested) { + + KisUndoAdapter * undo = 0; + if ((undo = image->undoAdapter()) && undo->undo()) { + undo->beginMacro(i18n("Separate Image")); + } + + // Flatten the image if required + switch(sourceOps) { + case(ALL_LAYERS): + image->flatten(); + break; + default: + break; + } + + for (TQValueVector<KisChannelInfo *>::const_iterator it = begin; it != end; ++it) + { + + KisChannelInfo * ch = (*it); + + if (ch->channelType() == KisChannelInfo::ALPHA && alphaOps != CREATE_ALPHA_SEPARATION) { + // Don't make an separate separation of the alpha channel if the user didn't ask for it. + continue; + } + + if (outputOps == TO_LAYERS) { + KisPaintLayerSP l = new KisPaintLayer( image, ch->name(), OPACITY_OPAQUE, *deviceIt); + image->addLayer( dynamic_cast<KisLayer*>(l.data()), image->rootLayer(), 0); + } + else { + TQStringList listMimeFilter = KoFilterManager::mimeFilter("application/x-chalk", KoFilterManager::Export); + TQString mimelist = listMimeFilter.join(" "); + + KFileDialog fd (TQString(), mimelist, m_view, "Export Layer", true); + fd.setCaption(i18n("Export Layer") + "(" + ch->name() + ")"); + fd.setMimeFilter(listMimeFilter); + fd.setOperationMode(KFileDialog::Saving); + fd.setURL(KURL(ch->name())); + if (!fd.exec()) return; + + KURL url = fd.selectedURL(); + TQString mimefilter = fd.currentMimeFilter(); + + if (url.isEmpty()) + return; + + KisPaintLayerSP l = new KisPaintLayer( image, ch->name(), OPACITY_OPAQUE, *deviceIt); + TQRect r = l->exactBounds(); + + KisDoc d; + d.prepareForImport(); + + KisImageSP dst = new KisImage(d.undoAdapter(), r.width(), r.height(), (*deviceIt)->colorSpace(), l->name()); + d.setCurrentImage( dst ); + dst->addLayer(l->clone(), dst->rootLayer(), 0); + + d.setOutputMimeType(mimefilter.latin1()); + d.exp0rt(url); + + } + + ++deviceIt; + } + + if (undo && undo->undo()) { + undo->endMacro(); + } + + m_view->canvasSubject()->document()->setModified(true); + } +} + + + + +#include "kis_channel_separator.moc" diff --git a/chalk/plugins/viewplugins/separate_channels/kis_channel_separator.h b/chalk/plugins/viewplugins/separate_channels/kis_channel_separator.h new file mode 100644 index 00000000..d8bf777e --- /dev/null +++ b/chalk/plugins/viewplugins/separate_channels/kis_channel_separator.h @@ -0,0 +1,70 @@ +/* + * This file is part of the KDE project + * + * Copyright (c) Michael Thaler <michael.thaler@physik.tu-muenchen.de> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef _KIS_CHANNEL_SEPARATOR_H_ +#define _KIS_CHANNEL_SEPARATOR_H_ + +#include <kis_progress_subject.h> + +class KisView; +class KisProgressDisplayInterface; + + +enum enumSepAlphaOptions { + COPY_ALPHA_TO_SEPARATIONS = 0, + DISCARD_ALPHA = 1, + CREATE_ALPHA_SEPARATION = 2 +}; + + +enum enumSepSource { + CURRENT_LAYER = 0, + ALL_LAYERS = 1, + VISIBLE_LAYERS = 2 +}; + +enum enumSepOutput { + TO_LAYERS = 0, + TO_IMAGES = 1 +}; + +class KisChannelSeparator : public KisProgressSubject { + + Q_OBJECT + TQ_OBJECT + +public: + + KisChannelSeparator(KisView * view); + virtual ~KisChannelSeparator() {}; + + void separate(KisProgressDisplayInterface * progress, enumSepAlphaOptions alphaOps, enumSepSource sourceOps, enumSepOutput outputOps, bool downscale, bool toColor); + +public: // Implement KisProgressSubject + virtual void cancel() { m_cancelRequested = true; } + + +private: + KisView * m_view; + bool m_cancelRequested; + +}; + +#endif diff --git a/chalk/plugins/viewplugins/separate_channels/kis_separate_channels_plugin.cc b/chalk/plugins/viewplugins/separate_channels/kis_separate_channels_plugin.cc new file mode 100644 index 00000000..64a83db5 --- /dev/null +++ b/chalk/plugins/viewplugins/separate_channels/kis_separate_channels_plugin.cc @@ -0,0 +1,96 @@ +/* + * This file is part of the KDE project + * + * Copyright (c) 2005 Michael Thaler <michael.thaler@physik.tu-muenchen.de> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include <klocale.h> +#include <kiconloader.h> +#include <kinstance.h> +#include <kmessagebox.h> +#include <kstandarddirs.h> +#include <ktempfile.h> +#include <kdebug.h> +#include <kgenericfactory.h> + +#include <kis_view.h> +#include <kis_types.h> +#include <kis_image.h> +#include <kis_paint_device.h> +#include <kis_layer.h> + +#include "kis_separate_channels_plugin.h" +#include "kis_channel_separator.h" +#include "dlg_separate.h" + +K_EXPORT_COMPONENT_FACTORY( chalkseparatechannels, KGenericFactory<KisSeparateChannelsPlugin>( "chalk" ) ) + +KisSeparateChannelsPlugin::KisSeparateChannelsPlugin(TQObject *tqparent, const char *name, const TQStringList &) + : KParts::Plugin(tqparent, name) +{ + + if ( tqparent->inherits("KisView") ) { + setInstance(KGenericFactory<KisSeparateChannelsPlugin>::instance()); + setXMLFile(locate("data","chalkplugins/imageseparate.rc"), true); + m_view = (KisView*) tqparent; + (void) new KAction(i18n("Separate Image..."), 0, 0, this, TQT_SLOT(slotSeparate()), actionCollection(), "separate"); + } +} + +KisSeparateChannelsPlugin::~KisSeparateChannelsPlugin() +{ +} + +void KisSeparateChannelsPlugin::slotSeparate() +{ + KisImageSP image = m_view->canvasSubject()->currentImg(); + if (!image) return; + + KisLayerSP l = image->activeLayer(); + if (!l) return; + + KisPaintDeviceSP dev = image->activeDevice(); + if (!dev) return; + + DlgSeparate * dlgSeparate = new DlgSeparate(dev->colorSpace()->id().name(), + image->colorSpace()->id().name(), m_view, "Separate"); + Q_CHECK_PTR(dlgSeparate); + + dlgSeparate->setCaption(i18n("Separate Image")); + + // If we're 8-bits, disable the downscale option + if (dev->pixelSize() == dev->nChannels()) { + dlgSeparate->enableDownscale(false); + } + + if (dlgSeparate->exec() == TQDialog::Accepted) { + + KisChannelSeparator separator(m_view); + separator.separate(m_view->canvasSubject()->progressDisplay(), + dlgSeparate->getAlphaOptions(), + dlgSeparate->getSource(), + dlgSeparate->getOutput(), + dlgSeparate->getDownscale(), + dlgSeparate->getToColor()); + + } + + delete dlgSeparate; + +} + +#include "kis_separate_channels_plugin.moc" diff --git a/chalk/plugins/viewplugins/separate_channels/kis_separate_channels_plugin.h b/chalk/plugins/viewplugins/separate_channels/kis_separate_channels_plugin.h new file mode 100644 index 00000000..ce3aa731 --- /dev/null +++ b/chalk/plugins/viewplugins/separate_channels/kis_separate_channels_plugin.h @@ -0,0 +1,46 @@ +/* + * This file is part of Chalk + * + * Copyright (c) Michael Thaler <michael.thaler@physik.tu-muenchen.de> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#ifndef _KIS_SEPARATE_CHANNELS_PLUGIN_H_ +#define _KIS_SEPARATE_CHANNELS_PLUGIN_H_ + +#include <kparts/plugin.h> + +class KisView; + + + +class KisSeparateChannelsPlugin : public KParts::Plugin +{ + Q_OBJECT + TQ_OBJECT +public: + KisSeparateChannelsPlugin(TQObject *tqparent, const char *name, const TQStringList &); + virtual ~KisSeparateChannelsPlugin(); + +private slots: + + void slotSeparate(); + +private: + + KisView * m_view; +}; + +#endif diff --git a/chalk/plugins/viewplugins/separate_channels/wdg_separations.ui b/chalk/plugins/viewplugins/separate_channels/wdg_separations.ui new file mode 100644 index 00000000..0593258b --- /dev/null +++ b/chalk/plugins/viewplugins/separate_channels/wdg_separations.ui @@ -0,0 +1,182 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>WdgSeparations</class> +<widget class="TQWidget"> + <property name="name"> + <cstring>WdgSeparations</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>570</width> + <height>350</height> + </rect> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQCheckBox" row="4" column="0" rowspan="1" colspan="3"> + <property name="name"> + <cstring>chkColors</cstring> + </property> + <property name="text"> + <string>Output to color, not grayscale</string> + </property> + </widget> + <widget class="TQCheckBox" row="3" column="0" rowspan="1" colspan="3"> + <property name="name"> + <cstring>chkDownscale</cstring> + </property> + <property name="text"> + <string>Downscale to 8-bit before separating</string> + </property> + </widget> + <widget class="TQButtonGroup" row="2" column="0" rowspan="1" colspan="3"> + <property name="name"> + <cstring>grpAlpha</cstring> + </property> + <property name="title"> + <string>Alpha Options</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQRadioButton"> + <property name="name"> + <cstring>radioCopyAlpha</cstring> + </property> + <property name="text"> + <string>Copy alpha channel to each separated channel as an alpha channel</string> + </property> + </widget> + <widget class="TQRadioButton"> + <property name="name"> + <cstring>radioDiscardAlpha</cstring> + </property> + <property name="text"> + <string>Discard alpha channel</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="TQRadioButton"> + <property name="name"> + <cstring>radioSeparateAlpha</cstring> + </property> + <property name="text"> + <string>Create separate separation from alpha channel</string> + </property> + </widget> + </vbox> + </widget> + <spacer row="5" column="1"> + <property name="name"> + <cstring>spacer1</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="tqsizeHint"> + <size> + <width>20</width> + <height>16</height> + </size> + </property> + </spacer> + <widget class="TQButtonGroup" row="1" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>grpSource</cstring> + </property> + <property name="title"> + <string>Source</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQRadioButton" row="0" column="0"> + <property name="name"> + <cstring>radioCurrentLayer</cstring> + </property> + <property name="text"> + <string>Current layer</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="TQRadioButton" row="1" column="0"> + <property name="name"> + <cstring>radioAllLayers</cstring> + </property> + <property name="text"> + <string>Flatten all layers before separation</string> + </property> + </widget> + </grid> + </widget> + <widget class="TQButtonGroup" row="1" column="2"> + <property name="name"> + <cstring>grpOutput</cstring> + </property> + <property name="title"> + <string>Output</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQRadioButton"> + <property name="name"> + <cstring>radioLayers</cstring> + </property> + <property name="text"> + <string>To layers</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="TQRadioButton"> + <property name="name"> + <cstring>radioImages</cstring> + </property> + <property name="text"> + <string>To images</string> + </property> + </widget> + </vbox> + </widget> + <widget class="TQLabel" row="0" column="1" rowspan="1" colspan="2"> + <property name="name"> + <cstring>lblColormodel</cstring> + </property> + <property name="text"> + <string></string> + </property> + </widget> + <widget class="TQLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="text"> + <string>Current color model:</string> + </property> + </widget> + </grid> +</widget> +<tabstops> + <tabstop>radioCurrentLayer</tabstop> + <tabstop>radioLayers</tabstop> + <tabstop>radioDiscardAlpha</tabstop> + <tabstop>chkDownscale</tabstop> + <tabstop>chkColors</tabstop> +</tabstops> +<tqlayoutdefaults spacing="6" margin="11"/> +</UI> |