summaryrefslogtreecommitdiffstats
path: root/filters/chalk/tiff
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-06-26 00:41:16 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-06-26 00:41:16 +0000
commit698569f8428ca088f764d704034a1330517b98c0 (patch)
treebf45be6946ebbbee9cce5a5bcf838f4c952d87e6 /filters/chalk/tiff
parent2785103a6bd4de55bd26d79e34d0fdd4b329a73a (diff)
downloadkoffice-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 'filters/chalk/tiff')
-rw-r--r--filters/chalk/tiff/Makefile.am55
-rw-r--r--filters/chalk/tiff/chalk_tiff.desktop63
-rw-r--r--filters/chalk/tiff/chalk_tiff_export.desktop52
-rw-r--r--filters/chalk/tiff/chalk_tiff_import.desktop52
-rw-r--r--filters/chalk/tiff/configure.in.bot7
-rw-r--r--filters/chalk/tiff/kis_dlg_options_tiff.cpp134
-rw-r--r--filters/chalk/tiff/kis_dlg_options_tiff.h45
-rw-r--r--filters/chalk/tiff/kis_tiff_converter.cc677
-rw-r--r--filters/chalk/tiff/kis_tiff_converter.h94
-rw-r--r--filters/chalk/tiff/kis_tiff_export.cc123
-rw-r--r--filters/chalk/tiff/kis_tiff_export.h35
-rw-r--r--filters/chalk/tiff/kis_tiff_import.cc105
-rw-r--r--filters/chalk/tiff/kis_tiff_import.h34
-rw-r--r--filters/chalk/tiff/kis_tiff_reader.cc121
-rw-r--r--filters/chalk/tiff/kis_tiff_reader.h206
-rw-r--r--filters/chalk/tiff/kis_tiff_stream.cc164
-rw-r--r--filters/chalk/tiff/kis_tiff_stream.h81
-rw-r--r--filters/chalk/tiff/kis_tiff_writer_visitor.cpp237
-rw-r--r--filters/chalk/tiff/kis_tiff_writer_visitor.h53
-rw-r--r--filters/chalk/tiff/kis_tiff_ycbcr_reader.cc170
-rw-r--r--filters/chalk/tiff/kis_tiff_ycbcr_reader.h73
-rw-r--r--filters/chalk/tiff/kis_wdg_options_tiff.ui741
-rw-r--r--filters/chalk/tiff/kis_ycbcr_colorspace.h27
23 files changed, 3349 insertions, 0 deletions
diff --git a/filters/chalk/tiff/Makefile.am b/filters/chalk/tiff/Makefile.am
new file mode 100644
index 00000000..2e120576
--- /dev/null
+++ b/filters/chalk/tiff/Makefile.am
@@ -0,0 +1,55 @@
+kde_module_LTLIBRARIES = libchalktiffimport.la libchalktiffexport.la
+
+libchalktiffexport_la_LDFLAGS = -avoid-version -module -no-undefined \
+ $(KDE_PLUGIN) $(KDE_RPATH) $(all_libraries) -lkdecore -lkdeui $(LIB_QT) -lkjs -lkdefx -lkio -lkparts \
+ -L../../../lib/kofficecore/.libs/ -lkofficecore -llcms \
+ -L../../../lib/kofficeui/.libs/ -lkofficeui -L../../../lib/store/.libs/ -lkstore -L../../../chalk/core/.libs/ -lchalkimage -L../../../chalk/ui/.libs/ -lchalkui -L../../../chalk/chalkcolor/.libs/ -lchalkcolor
+libchalktiffexport_la_LIBADD = $(top_builddir)/chalk/libchalkcommon.la \
+ libchalktiffconverter.la $(KOFFICE_LIBS) -ltiff
+
+libchalktiffimport_la_LDFLAGS = -avoid-version -module -no-undefined \
+ $(KDE_PLUGIN) $(KDE_RPATH) $(all_libraries) -lkdecore -lkdeui $(LIB_QT) -lkjs -lkdefx -lkio -lkparts \
+ -L../../../lib/kofficecore/.libs/ -lkofficecore -llcms \
+ -L../../../lib/kofficeui/.libs/ -lkofficeui -L../../../lib/store/.libs/ -lkstore -L../../../chalk/core/.libs/ -lchalkimage -L../../../chalk/ui/.libs/ -lchalkui -L../../../chalk/chalkcolor/.libs/ -lchalkcolor
+libchalktiffimport_la_LIBADD = $(top_builddir)/chalk/libchalkcommon.la \
+ libchalktiffconverter.la $(KOFFICE_LIBS) -ltiff
+
+INCLUDES= \
+ -I$(srcdir) \
+ $(KOFFICE_INCLUDES) \
+ -I$(top_srcdir)/chalk \
+ -I$(top_srcdir)/chalk/core \
+ -I$(top_srcdir)/chalk/sdk \
+ -I$(top_srcdir)/chalk/core/tiles \
+ -I$(top_srcdir)/chalk/chalkcolor \
+ -I$(top_srcdir)/chalk/ui \
+ $(KOFFICE_INCLUDES) -I$(interfacedir) \
+ $(KOPAINTER_INCLUDES) \
+ $(all_includes)
+
+
+servicedir = $(kde_servicesdir)
+
+
+kdelnkdir = $(kde_appsdir)/.hidden
+
+
+
+
+METASOURCES = AUTO
+
+
+KDE_CXXFLAGS = $(USE_EXCEPTIONS)
+libchalktiffimport_la_SOURCES = kis_tiff_import.cc
+libchalktiffexport_la_SOURCES = kis_tiff_export.cc kis_wdg_options_tiff.ui \
+ kis_dlg_options_tiff.cpp
+service_DATA = chalk_tiff_export.desktop chalk_tiff_import.desktop
+kdelnk_DATA = chalk_tiff.desktop
+noinst_HEADERS = kis_dlg_options_tiff.h kis_tiff_writer_visitor.h \
+ kis_tiff_ycbcr_reader.h
+libchalktiffconverter_la_LDFLAGS = -no-undefined $(all_libraries) -lkdecore -lkdeui $(LIB_QT) -lkjs -lkdefx -lkio -lkparts \
+ -L../../../lib/kofficecore/.libs/ -lkofficecore -llcms \
+ -L../../../lib/kofficeui/.libs/ -lkofficeui -L../../../lib/store/.libs/ -lkstore -L../../../chalk/core/.libs/ -lchalkimage -L../../../chalk/ui/.libs/ -lchalkui -L../../../chalk/chalkcolor/.libs/ -lchalkcolor
+noinst_LTLIBRARIES = libchalktiffconverter.la
+libchalktiffconverter_la_SOURCES = kis_tiff_converter.cc kis_tiff_stream.cc \
+ kis_tiff_writer_visitor.cpp kis_tiff_reader.cc kis_tiff_ycbcr_reader.cc
diff --git a/filters/chalk/tiff/chalk_tiff.desktop b/filters/chalk/tiff/chalk_tiff.desktop
new file mode 100644
index 00000000..55cd1033
--- /dev/null
+++ b/filters/chalk/tiff/chalk_tiff.desktop
@@ -0,0 +1,63 @@
+[Desktop Entry]
+Categories=
+Exec=chalk %u
+GenericName=Painting and Image Editing Application
+GenericName[bg]=Редактор на графични изображения
+GenericName[ca]=Programa de dibuix i manipulació d'imatges
+GenericName[cs]=Malování a úpravy obrázků
+GenericName[cy]=Cymhwysiad Peintio Golygu Delweddau
+GenericName[da]=Male- og billedredigeringsprogram
+GenericName[de]=Mal- und Bildbearbeitungsprogramm
+GenericName[el]=Εφαρμογή επεξεργασίας εικόνων
+GenericName[eo]=Aplikaĵo por Pentrado kaj Bildredaktado
+GenericName[es]=Aplicación de pintura y de edición de imágenes
+GenericName[et]=Joonistamise ja pilditöötluse rakendus
+GenericName[eu]=Irudien marrazketa eta ediziorako aplikazioa
+GenericName[fa]=کاربرد ویرایش تصویر و نقاشی
+GenericName[fi]=Maalaus- ja kuvankäsitelyohjelma
+GenericName[fr]=Application de dessin et de manipulation d'images
+GenericName[fy]=Ofbyldingsmanipulaasje
+GenericName[gl]=Aplicación de Pintura e Manipulación de Imaxes
+GenericName[he]=יישום לציור ועריכת תמונות
+GenericName[hr]=Aplikacija za obradu slika i fotografija
+GenericName[hu]=Képszerkesztő
+GenericName[is]=Málun og myndritill
+GenericName[it]=Applicazione di disegno e di modifica delle immagini
+GenericName[ja]=描画と画像編集のためのアプリケーション
+GenericName[km]=កម្មវិធី​គូរ​គំនូរ និង​កែសម្រួល​រូបភាព
+GenericName[lv]=Zīmēšanas un attēlu apstrādes programma
+GenericName[nb]=Program for tegning og bilderedigering
+GenericName[nds]=Programm för't Malen un Bildbewerken
+GenericName[ne]=पेन्टीङ्ग र छवि सम्पादन अनुप्रयोग
+GenericName[nl]=Afbeeldingsmanipulatie
+GenericName[pl]=Program do edycji zdjęć oraz rysunków
+GenericName[pt]=Aplicação de Pintura e Edição de Imagens
+GenericName[pt_BR]=Aplicação de Pintura e Edição de Imagens
+GenericName[ru]=Растровые изображения
+GenericName[se]=Málen- ja govvagieđahallanprográmma
+GenericName[sk]=Program pre tvorbu a úpravu obrázkov
+GenericName[sl]=Program za risanje in obdelavo slik
+GenericName[sr]=Програм за цртање и уређивање слика
+GenericName[sr@Latn]=Program za crtanje i uređivanje slika
+GenericName[sv]=Målnings- och bildredigeringsprogram
+GenericName[uk]=Програма для малювання і редагування зображень
+GenericName[uz]=Rasmlar bilan ishlaydigan dastur
+GenericName[uz@cyrillic]=Расмлар билан ишлайдиган дастур
+GenericName[zh_CN]=绘图和图像编辑应用程序
+GenericName[zh_TW]=繪圖與影像處理程式
+Icon=chalk
+MimeType=image/tiff
+Name=Chalk
+Name[hi]=के-रिता
+Name[km]= Chalk
+Name[lo]=ກຣິຕາ
+Name[ne]=क्रिता
+Path=
+StartupNotify=true
+Terminal=false
+TerminalOptions=
+Type=Application
+X-DCOP-ServiceType=multi
+X-KDE-StartupNotify=true
+X-KDE-SubstituteUID=false
+X-KDE-Username=
diff --git a/filters/chalk/tiff/chalk_tiff_export.desktop b/filters/chalk/tiff/chalk_tiff_export.desktop
new file mode 100644
index 00000000..3f174827
--- /dev/null
+++ b/filters/chalk/tiff/chalk_tiff_export.desktop
@@ -0,0 +1,52 @@
+[Desktop Entry]
+Icon=
+Name=Chalk TIFF Export Filter
+Name[bg]=Филтър за експортиране от Chalk в TIFF
+Name[br]=Sil ezporzh TIFF evit Chalk
+Name[ca]=Filtre d'exportació TIFF per a Chalk
+Name[da]=Chalk TIFF-eksportfilter
+Name[de]=Chalk TIFF-Exportfilter
+Name[el]=Φίλτρο εξαγωγής TIFF του Chalk
+Name[eo]=Chalk TIFF-eksportfiltrilo
+Name[es]=Filtro de exportación a TIFF de Chalk
+Name[et]=Chalk TIFF-i ekspordifilter
+Name[fa]=پالایۀ صادرات Chalk TIFF
+Name[fi]=Chalk TIFF -vientisuodin
+Name[fr]=Filtre d'exportation TIFF de Chalk
+Name[fy]=Chalk TIFF Eksportfilter
+Name[ga]=Scagaire Easpórtála TIFF Chalk
+Name[gl]=Filtro de Exportación de TIFF para Chalk
+Name[he]=Chalk TIFF מסנן יצוא
+Name[hr]=Chalk TIFF filtar izvoza
+Name[hu]=Chalk TIFF exportszűrő
+Name[is]=Chalk TIFF útflutningssía
+Name[it]=Filtro di esportazione TIFF per Chalk
+Name[ja]=Chalk TIFF エクスポートフィルタ
+Name[km]=តម្រង​នាំចេញ TIFF សម្រាប់ Chalk
+Name[lt]=Chalk TIFF eksportavimo filtras
+Name[lv]=Chalk TIFF eksporta filtrs
+Name[nb]=TIFF-eksportfilter for Chalk
+Name[nds]=TIFF-Exportfilter för Chalk
+Name[ne]=क्रिता TIFF निर्यात फिल्टर
+Name[nl]=Chalk TIFF Exportfilter
+Name[pl]=Filtr eksportu do formatu TIFF dla Chalk
+Name[pt]=Filtro de Exportação de TIFF para o Chalk
+Name[pt_BR]=Filtro de Exportação de TIFF para o Chalk
+Name[ru]=Фильтр экспорта рисунков Chalk в TIFF
+Name[se]=Chalk Tiff-olggosfievrridansilli
+Name[sk]=Exportný filter Chalk TIFF
+Name[sl]=Izvozni filter TIFF za Krito
+Name[sr]=Chalk-ин филтер за извоз у TIFF
+Name[sr@Latn]=Chalk-in filter za izvoz u TIFF
+Name[sv]=Chalk TIFF-exportfilter
+Name[uk]=Фільтр експорту TIFF для Chalk
+Name[uz]=Chalk TIFF eksport filteri
+Name[uz@cyrillic]=Chalk TIFF экспорт филтери
+Name[zh_CN]=Chalk TIFF 导出过滤器
+Name[zh_TW]=Chalk TIFF 匯出過濾程式
+ServiceTypes=KOfficeFilter
+Type=Service
+X-KDE-Export=image/tiff
+X-KDE-Import=application/x-chalk
+X-KDE-Library=libchalktiffexport
+X-KDE-Weight=1
diff --git a/filters/chalk/tiff/chalk_tiff_import.desktop b/filters/chalk/tiff/chalk_tiff_import.desktop
new file mode 100644
index 00000000..593b0eee
--- /dev/null
+++ b/filters/chalk/tiff/chalk_tiff_import.desktop
@@ -0,0 +1,52 @@
+[Desktop Entry]
+Icon=
+Name=Chalk TIFF Import Filter
+Name[bg]=Филтър за импортиране от TIFF в Chalk
+Name[br]=Sil enporzh TIFF evit Chalk
+Name[ca]=Filtre d'importació TIFF per a Chalk
+Name[da]=Chalk TIFF-importfilter
+Name[de]=Chalk TIFF-Importfilter
+Name[el]=Φίλτρο εισαγωγής TIFF του Chalk
+Name[eo]=Chalk TIFF-importfiltrilo
+Name[es]=Filtro de importación desde TIFF de Chalk
+Name[et]=Chalk TIFF-i impordifilter
+Name[fa]=پالایۀ واردات Chalk TIFF
+Name[fi]=Chalk TIFF -tuontisuodin
+Name[fr]=Filtre d'importation TIFF de Chalk
+Name[fy]=Chalk TIFF Ymportfilter
+Name[ga]=Scagaire Iompórtála TIFF Chalk
+Name[gl]=Filtro de Importación de TIFF para Chalk
+Name[he]=Chalk TIFF מסנן יבוא
+Name[hr]=Chalk TIFF filtar uvoza
+Name[hu]=Chalk TIFF importszűrő
+Name[is]=Chalk TIFF innflutningssía
+Name[it]=Filtro di importazione TIFF per Chalk
+Name[ja]=Chalk TIFF インポートフィルタ
+Name[km]=តម្រង​នាំចូល TIFF សម្រាប់ Chalk
+Name[lt]=Chalk TIFF importavimo filtras
+Name[lv]=Chalk TIFF importa filtrs
+Name[nb]=TIFF-importfilter for Chalk
+Name[nds]=TIFF-Importfilter för Chalk
+Name[ne]=क्रिता TIFF आयात फिल्टर
+Name[nl]=Chalk TIFF Importfilter
+Name[pl]=Filtr importu formatu TIFF dla Chalk
+Name[pt]=Filtro de Importação de TIFF para o Chalk
+Name[pt_BR]=Filtro de Importação de TIFF para o Chalk
+Name[ru]=Фильтр импорта рисунков TIFF в Chalk
+Name[se]=Chalk TIFF-sisafievrridansilli
+Name[sk]=TIFF filter pre import do Chalk
+Name[sl]=Uvozni filter TIFF za Krito
+Name[sr]=Chalk-ин филтер за увоз из TIFF-а
+Name[sr@Latn]=Chalk-in filter za uvoz iz TIFF-a
+Name[sv]=Chalk TIFF-importfilter
+Name[uk]=Фільтр імпорту TIFF для Chalk
+Name[uz]=Chalk TIFF import filteri
+Name[uz@cyrillic]=Chalk TIFF импорт филтери
+Name[zh_CN]=Chalk TIFF 导入过滤器
+Name[zh_TW]=Chalk TIFF 匯入過濾程式
+ServiceTypes=KOfficeFilter
+Type=Service
+X-KDE-Export=application/x-chalk
+X-KDE-Import=image/tiff
+X-KDE-Library=libchalktiffimport
+X-KDE-Weight=1
diff --git a/filters/chalk/tiff/configure.in.bot b/filters/chalk/tiff/configure.in.bot
new file mode 100644
index 00000000..8458154d
--- /dev/null
+++ b/filters/chalk/tiff/configure.in.bot
@@ -0,0 +1,7 @@
+if test -z "$LIBTIFF"; then
+ echo ""
+ echo "You're missing libtiff (binaries and/or headers), chalk won't be able"
+ echo "to import/export tiff"
+ echo ""
+ all_tests=bad
+fi
diff --git a/filters/chalk/tiff/kis_dlg_options_tiff.cpp b/filters/chalk/tiff/kis_dlg_options_tiff.cpp
new file mode 100644
index 00000000..345f7e7e
--- /dev/null
+++ b/filters/chalk/tiff/kis_dlg_options_tiff.cpp
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2005 Cyrille Berger <[email protected]>
+ *
+ * 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 "kis_dlg_options_tiff.h"
+
+#include <tqcheckbox.h>
+#include <tqgroupbox.h>
+#include <tqslider.h>
+#include <tqwidgetstack.h>
+
+#include <kapplication.h>
+#include <kcombobox.h>
+#include <klocale.h>
+
+#include "kis_wdg_options_tiff.h"
+
+KisDlgOptionsTIFF::KisDlgOptionsTIFF(TQWidget *tqparent, const char *name)
+ : KDialogBase(tqparent, name, false, i18n("TIFF Export Options"), KDialogBase::Ok | KDialogBase::Cancel)
+{
+ optionswdg = new KisWdgOptionsTIFF(this);
+ activated(0);
+ connect(optionswdg->kComboBoxCompressionType, TQT_SIGNAL(activated ( int )), this, TQT_SLOT(activated ( int ) ));
+ connect(optionswdg->flatten, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(flattenToggled( bool) ) );
+ setMainWidget(optionswdg);
+ kapp->restoreOverrideCursor();
+ tqsetSizePolicy(TQSizePolicy(TQSizePolicy::Minimum, TQSizePolicy::Minimum) );
+}
+
+KisDlgOptionsTIFF::~KisDlgOptionsTIFF()
+{
+}
+
+void KisDlgOptionsTIFF::activated ( int index )
+{
+/* optionswdg->groupBoxJPEG->hide();
+ optionswdg->groupBoxDeflate->hide();
+ optionswdg->groupBoxCCITGroupCCITG3->hide();
+ optionswdg->groupBoxPixarLog->hide();*/
+ switch(index)
+ {
+ case 1:
+ optionswdg->codecsOptionsStack->raiseWidget(1);
+// optionswdg->groupBoxJPEG->show();
+ break;
+ case 2:
+ optionswdg->codecsOptionsStack->raiseWidget(2);
+// optionswdg->groupBoxDeflate->show();
+ break;
+ case 6:
+ optionswdg->codecsOptionsStack->raiseWidget(3);
+// optionswdg->groupBoxCCITGroupCCITG3->show();
+ break;
+ case 8:
+ optionswdg->codecsOptionsStack->raiseWidget(4);
+// optionswdg->groupBoxPixarLog->show();
+ break;
+ default:
+ optionswdg->codecsOptionsStack->raiseWidget(0);
+ }
+}
+
+void KisDlgOptionsTIFF::flattenToggled(bool t)
+{
+ optionswdg->alpha->setEnabled(t);
+ if(!t)
+ {
+ optionswdg->alpha->setChecked(true);
+ }
+}
+
+
+KisTIFFOptions KisDlgOptionsTIFF::options()
+{
+ KisTIFFOptions options;
+ switch(optionswdg->kComboBoxCompressionType->currentItem ())
+ {
+ case 0:
+ options.compressionType = COMPRESSION_NONE;
+ break;
+ case 1:
+ options.compressionType = COMPRESSION_JPEG;
+ break;
+ case 2:
+ options.compressionType = COMPRESSION_DEFLATE;
+ break;
+ case 3:
+ options.compressionType = COMPRESSION_LZW;
+ break;
+#ifdef COMPRESSION_JP2000
+ case 4:
+ options.compressionType = COMPRESSION_JP2000;
+ break;
+#endif
+ case 5:
+ options.compressionType = COMPRESSION_CCITTRLE;
+ break;
+ case 6:
+ options.compressionType = COMPRESSION_CCITTFAX3;
+ break;
+ case 7:
+ options.compressionType = COMPRESSION_CCITTFAX4;
+ break;
+ case 8:
+ options.compressionType = COMPRESSION_PIXARLOG;
+ break;
+ }
+ options.predictor = optionswdg->kComboBoxPredictor->currentItem() + 1;
+ options.alpha = optionswdg->alpha->isChecked();
+ options.flatten = optionswdg->flatten->isChecked();
+ options.jpegQuality = optionswdg->qualityLevel->value();
+ options.deflateCompress = optionswdg->compressionLevelDeflate->value();
+ options.faxMode = optionswdg->kComboBoxFaxMode->currentItem() + 1;
+ options.pixarLogCompress = optionswdg->compressionLevelPixarLog->value();
+
+ return options;
+}
+
+#include "kis_dlg_options_tiff.moc"
diff --git a/filters/chalk/tiff/kis_dlg_options_tiff.h b/filters/chalk/tiff/kis_dlg_options_tiff.h
new file mode 100644
index 00000000..5fd1e48e
--- /dev/null
+++ b/filters/chalk/tiff/kis_dlg_options_tiff.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2005-2006 Cyrille Berger <[email protected]>
+ *
+ * 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_DLG_OPTIONS_TIFF_H
+#define KIS_DLG_OPTIONS_TIFF_H
+
+#include <kdialogbase.h>
+#include <kis_tiff_converter.h>
+
+class KisWdgOptionsTIFF;
+/**
+ @author Cyrille Berger <[email protected]>
+*/
+class KisDlgOptionsTIFF : public KDialogBase
+{
+ Q_OBJECT
+ TQ_OBJECT
+ public:
+ KisDlgOptionsTIFF(TQWidget *tqparent=0, const char *name=0);
+ ~KisDlgOptionsTIFF();
+ public slots:
+ void activated ( int index );
+ void flattenToggled(bool);
+ KisTIFFOptions options();
+ public:
+ KisWdgOptionsTIFF* optionswdg;
+};
+
+#endif
diff --git a/filters/chalk/tiff/kis_tiff_converter.cc b/filters/chalk/tiff/kis_tiff_converter.cc
new file mode 100644
index 00000000..09a0ba99
--- /dev/null
+++ b/filters/chalk/tiff/kis_tiff_converter.cc
@@ -0,0 +1,677 @@
+/*
+ * Copyright (c) 2005-2006 Cyrille Berger <[email protected]>
+ *
+ * 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 "kis_tiff_converter.h"
+
+#include <stdio.h>
+
+#include <config.h>
+#include LCMS_HEADER
+
+#include <tqfile.h>
+
+#include <kapplication.h>
+#include <KoDocumentInfo.h>
+
+#include <kio/netaccess.h>
+
+#include <kis_abstract_colorspace.h>
+#include <kis_colorspace_factory_registry.h>
+#include <kis_doc.h>
+#include <kis_image.h>
+#include <kis_iterators_pixel.h>
+#include <kis_layer.h>
+#include <kis_meta_registry.h>
+#include <kis_profile.h>
+#include <kis_group_layer.h>
+#include <kis_paint_layer.h>
+
+#include "kis_tiff_reader.h"
+#include "kis_tiff_ycbcr_reader.h"
+#include "kis_tiff_stream.h"
+#include "kis_tiff_writer_visitor.h"
+
+namespace {
+
+ TQString getColorSpaceForColorType(uint16 color_type, uint16 color_nb_bits, TIFF *image, uint16 &nbchannels, uint16 &extrasamplescount, uint8 &destDepth, uint16 sampletype) {
+ if(color_type == PHOTOMETRIC_MINISWHITE || color_type == PHOTOMETRIC_MINISBLACK)
+ {
+ if(nbchannels == 0) nbchannels = 1;
+ extrasamplescount = nbchannels - 1; // FIX the extrasamples count in case of
+ if(color_nb_bits <= 8)
+ {
+ destDepth = 8;
+ return "GRAYA";
+ } else {
+ destDepth = 16;
+ return "GRAYA16";
+ }
+ } else if(color_type == PHOTOMETRIC_RGB /*|| color_type == */ ) {
+ if(nbchannels == 0) nbchannels = 3;
+ extrasamplescount = nbchannels - 3; // FIX the extrasamples count in case of
+ if(sampletype == SAMPLEFORMAT_IEEEFP)
+ {
+ if(color_nb_bits == 16)
+ {
+ destDepth = 16;
+ return "RGBAF16HALF";
+ } else if( color_nb_bits == 32) {
+ destDepth = 32;
+ return "RGBAF32";
+ }
+ return "";
+ } else {
+ if(color_nb_bits <= 8)
+ {
+ destDepth = 8;
+ return "RGBA";
+ } else {
+ destDepth = 16;
+ return "RGBA16";
+ }
+ }
+ } else if(color_type == PHOTOMETRIC_YCBCR ) {
+ if(nbchannels == 0) nbchannels = 3;
+ extrasamplescount = nbchannels - 3; // FIX the extrasamples count in case of
+ if(color_nb_bits <= 8)
+ {
+ destDepth = 8;
+ return "YCbCrAU8";
+ } else {
+ destDepth = 16;
+ return "YCbCrAU16";
+ }
+ } else if(color_type == PHOTOMETRIC_SEPARATED ) {
+ if(nbchannels == 0) nbchannels = 4;
+ // SEPARATED is in general CMYK but not allways, so we check
+ uint16 inkset;
+ if((TIFFGetField(image, TIFFTAG_INKSET, &inkset) == 0)){
+ kdDebug(41008) << "Image does not define the inkset." << endl;
+ inkset = 2;
+ }
+ if(inkset != INKSET_CMYK)
+ {
+ kdDebug(41008) << "Unsupported inkset (right now, only CMYK is supported)" << endl;
+ char** ink_names;
+ uint16 numberofinks;
+ if( TIFFGetField(image, TIFFTAG_INKNAMES, &ink_names) && TIFFGetField(image, TIFFTAG_NUMBEROFINKS, &numberofinks) )
+ {
+ kdDebug(41008) << "Inks are : " << endl;
+ for(uint i = 0; i < numberofinks; i++)
+ {
+ kdDebug(41008) << ink_names[i] << endl;
+ }
+ } else {
+ kdDebug(41008) << "inknames aren't defined !" << endl;
+ // To be able to read stupid adobe files, if there are no information about inks and four channels, then it's a CMYK file :
+ if( nbchannels - extrasamplescount != 4)
+ {
+ return "";
+ }
+ }
+ }
+ if(color_nb_bits <= 8)
+ {
+ destDepth = 8;
+ return "CMYK";
+ } else {
+ destDepth = 16;
+ return "CMYKA16";
+ }
+ } else if(color_type == PHOTOMETRIC_CIELAB
+#ifdef PHOTOMETRIC_ICCLAB
+ || color_type == PHOTOMETRIC_ICCLAB
+#endif
+ ) {
+ destDepth = 16;
+ if(nbchannels == 0) nbchannels = 3;
+ extrasamplescount = nbchannels - 3; // FIX the extrasamples count in case of
+ return "LABA"; // TODO add support for a 8bit LAB colorspace when it is written
+ } else if(color_type == PHOTOMETRIC_PALETTE) {
+ destDepth = 16;
+ if(nbchannels == 0) nbchannels = 2;
+ extrasamplescount = nbchannels - 2; // FIX the extrasamples count in case of
+ // <-- we will convert the index image to RGBA16 as the palette is allways on 16bits colors
+ return "RGBA16";
+ }
+ return "";
+ }
+}
+
+KisTIFFConverter::KisTIFFConverter(KisDoc *doc, KisUndoAdapter *adapter)
+{
+ m_doc = doc;
+ m_adapter = adapter;
+ m_job = 0;
+ m_stop = false;
+}
+
+KisTIFFConverter::~KisTIFFConverter()
+{
+}
+
+KisImageBuilder_Result KisTIFFConverter::decode(const KURL& uri)
+{
+ kdDebug(41008) << "Start decoding TIFF File" << endl;
+ // Opent the TIFF file
+ TIFF *image = 0;
+ if((image = TIFFOpen(TQFile::encodeName(uri.path()), "r")) == NULL){
+ kdDebug(41008) << "Could not open the file, either it doesn't exist, either it is not a TIFF : " << uri.path() << endl;
+
+ return (KisImageBuilder_RESULT_BAD_FETCH);
+ }
+ do {
+ kdDebug(41008) << "Read new sub-image" << endl;
+ KisImageBuilder_Result result = readTIFFDirectory(image);
+ if(result != KisImageBuilder_RESULT_OK){
+ return result;
+ }
+ } while (TIFFReadDirectory(image));
+ // Freeing memory
+ TIFFClose(image);
+ return KisImageBuilder_RESULT_OK;
+}
+
+KisImageBuilder_Result KisTIFFConverter::readTIFFDirectory( TIFF* image)
+{
+ // Read information about the tiff
+ uint32 width, height;
+ if(TIFFGetField(image, TIFFTAG_IMAGEWIDTH, &width) == 0){
+ kdDebug(41008) << "Image does not define its width" << endl;
+ TIFFClose(image);
+ return KisImageBuilder_RESULT_INVALID_ARG;
+ }
+ if(TIFFGetField(image, TIFFTAG_IMAGELENGTH, &height) == 0){
+ kdDebug(41008) << "Image does not define its height" << endl;
+ TIFFClose(image);
+ return KisImageBuilder_RESULT_INVALID_ARG;
+ }
+ uint16 depth;
+ if((TIFFGetField(image, TIFFTAG_BITSPERSAMPLE, &depth) == 0)){
+ kdDebug(41008) << "Image does not define its depth" << endl;
+ depth = 1;
+ }
+ uint16 sampletype;
+ if((TIFFGetField(image, TIFFTAG_SAMPLEFORMAT, &sampletype) == 0)){
+ kdDebug(41008) << "Image does not define its sample type" << endl;
+ sampletype = SAMPLEFORMAT_UINT;
+ }
+ // Determine the number of channels (usefull to know if a file has an alpha or not
+ uint16 nbchannels;
+ if(TIFFGetField(image, TIFFTAG_SAMPLESPERPIXEL, &nbchannels) == 0){
+ kdDebug(41008) << "Image has an undefined number of samples per pixel" << endl;
+ nbchannels = 0;
+ }
+ // Get the number of extrasamples and information about them
+ uint16 *sampleinfo, extrasamplescount;
+ if(TIFFGetField(image, TIFFTAG_EXTRASAMPLES, &extrasamplescount, &sampleinfo) == 0)
+ {
+ extrasamplescount = 0;
+ }
+ // Determine the colorspace
+ uint16 color_type;
+ if(TIFFGetField(image, TIFFTAG_PHOTOMETRIC, &color_type) == 0){
+ kdDebug(41008) << "Image has an undefined photometric interpretation" << endl;
+ color_type = PHOTOMETRIC_MINISWHITE;
+ }
+ uint8 dstDepth;
+ TQString csName = getColorSpaceForColorType(color_type, depth, image, nbchannels, extrasamplescount, dstDepth,sampletype);
+ if(csName.isEmpty()) {
+ kdDebug(41008) << "Image has an unsupported colorspace : " << color_type << " for this depth : "<< depth << endl;
+ TIFFClose(image);
+ return KisImageBuilder_RESULT_UNSUPPORTED_COLORSPACE;
+ }
+ kdDebug(41008) << "Colorspace is : " << csName << " with a depth of " << depth << " and with a nb of channels of " << nbchannels << endl;
+
+ // Read image profile
+ kdDebug() << "Reading profile" << endl;
+ KisProfile* profile = 0;
+ DWORD EmbedLen;
+ LPBYTE EmbedBuffer;
+
+ if (TIFFGetField(image, TIFFTAG_ICCPROFILE, &EmbedLen, &EmbedBuffer)) {
+ kdDebug(41008) << "Profile found" << endl;
+ TQByteArray rawdata;
+ rawdata.resize(EmbedLen);
+ memcpy(rawdata.data(), EmbedBuffer, EmbedLen);
+ profile = new KisProfile(rawdata);
+ } else {
+ kdDebug(41008) << "No Profile found" << endl;
+ }
+
+ // Retrieve a pointer to the colorspace
+ KisColorSpace* cs = 0;
+ if (profile && profile->isSuitableForOutput())
+ {
+ kdDebug(41008) << "image has embedded profile: " << profile -> productName() << "\n";
+ cs = KisMetaRegistry::instance()->csRegistry()->getColorSpace(csName, profile);
+ }
+ else
+ cs = KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID(csName,""),"");
+
+ if(cs == 0) {
+ kdDebug(41008) << "Colorspace " << csName << " is not available, please check your installation." << endl;
+ TIFFClose(image);
+ return KisImageBuilder_RESULT_UNSUPPORTED_COLORSPACE;
+ }
+
+ // Create the cmsTransform if needed
+ cmsHTRANSFORM transform = 0;
+ if(profile && !profile->isSuitableForOutput())
+ {
+ kdDebug(41008) << "The profile can't be used in chalk, need conversion" << endl;
+ transform = cmsCreateTransform(profile->profile(), cs->colorSpaceType(),
+ cs->getProfile()->profile() , cs->colorSpaceType(),
+ INTENT_PERCEPTUAL, 0);
+ }
+
+
+ // Check if there is an alpha channel
+ int8 alphapos = -1; // <- no alpha
+ // Check which extra is alpha if any
+ kdDebug(41008) << "There are " << nbchannels << " channels and " << extrasamplescount << " extra channels" << endl;
+ if(sampleinfo) // index images don't have any sampleinfo, and therefor sampleinfo == 0
+ {
+ for(int i = 0; i < extrasamplescount; i ++)
+ {
+ kdDebug(41008) << i << " " << extrasamplescount << " " << (cs->nColorChannels()) << nbchannels << " " << sampleinfo[i] << endl;
+ if(sampleinfo[i] == EXTRASAMPLE_ASSOCALPHA)
+ {
+ // XXX: dangelo: the color values are already multiplied with
+ // the alpha value. This needs to be reversed later (postprocessor?)
+ alphapos = i;
+ }
+
+ if (sampleinfo[i] == EXTRASAMPLE_UNASSALPHA)
+ {
+ // color values are not premultiplied with alpha, and can be used as they are.
+ alphapos = i;
+ }
+ }
+ }
+
+ // Read META Information
+ KoDocumentInfo * info = m_doc->documentInfo();
+ KoDocumentInfoAbout * aboutPage = static_cast<KoDocumentInfoAbout *>(info->page( "about" ));
+ KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author"));
+ char* text;
+ if (TIFFGetField(image, TIFFTAG_ARTIST, &text)) {
+ authorPage->setFullName(text);
+ }
+ if (TIFFGetField(image, TIFFTAG_DOCUMENTNAME, &text)) {
+ aboutPage->setTitle(text);
+ }
+ if (TIFFGetField(image,TIFFTAG_IMAGEDESCRIPTION,&text) ) {
+ aboutPage->setAbstract( text );
+ }
+
+
+ // Get the planar configuration
+ uint16 planarconfig;
+ if(TIFFGetField(image, TIFFTAG_PLANARCONFIG, &planarconfig) == 0)
+ {
+ kdDebug(41008) << "Plannar configuration is not define" << endl;
+ TIFFClose(image);
+ return KisImageBuilder_RESULT_INVALID_ARG;
+ }
+ // Creating the KisImageSP
+ if( ! m_img ) {
+ m_img = new KisImage(m_doc->undoAdapter(), width, height, cs, "built image");
+ Q_CHECK_PTR(m_img);
+ m_img->blockSignals(true); // Don't send out signals while we're building the image
+ if(profile)
+ {
+ m_img -> addAnnotation( profile->annotation() );
+ }
+ } else {
+ if( m_img->width() < (TQ_INT32)width || m_img->height() < (TQ_INT32)height)
+ {
+ TQ_UINT32 newwidth = (m_img->width() < (TQ_INT32)width) ? width : m_img->width();
+ TQ_UINT32 newheight = (m_img->height() < (TQ_INT32)height) ? height : m_img->height();
+ m_img->resize(newwidth, newheight, false);
+ }
+ }
+ KisPaintLayer* layer = new KisPaintLayer(m_img, m_img -> nextLayerName(), TQ_UINT8_MAX);
+ tdata_t buf = 0;
+ tdata_t* ps_buf = 0; // used only for planar configuration seperated
+ TIFFStreamBase* tiffstream;
+
+ KisTIFFReaderBase* tiffReader = 0;
+
+ TQ_UINT8 poses[5];
+ KisTIFFPostProcessor* postprocessor = 0;
+
+ // Configure poses
+ uint8 nbcolorsamples = nbchannels - extrasamplescount;
+ switch(color_type)
+ {
+ case PHOTOMETRIC_MINISWHITE:
+ {
+ poses[0] = 0; poses[1] = 1;
+ postprocessor = new KisTIFFPostProcessorInvert(nbcolorsamples);
+ }
+ break;
+ case PHOTOMETRIC_MINISBLACK:
+ {
+ poses[0] = 0; poses[1] = 1;
+ postprocessor = new KisTIFFPostProcessor(nbcolorsamples);
+ }
+ break;
+ case PHOTOMETRIC_CIELAB:
+ {
+ poses[0] = 0; poses[1] = 1; poses[2] = 2; poses[3] = 3;
+ postprocessor = new KisTIFFPostProcessorICCLABtoCIELAB(nbcolorsamples);
+ }
+ break;
+#ifdef PHOTOMETRIC_ICCLAB
+ case PHOTOMETRIC_ICCLAB:
+ {
+ poses[0] = 0; poses[1] = 1; poses[2] = 2; poses[3] = 3;
+ postprocessor = new KisTIFFPostProcessor(nbcolorsamples);
+ }
+ break;
+#endif
+ case PHOTOMETRIC_RGB:
+ {
+ poses[0] = 2; poses[1] = 1; poses[2] = 0; poses[3] = 3;
+ postprocessor = new KisTIFFPostProcessor(nbcolorsamples);
+ }
+ break;
+ case PHOTOMETRIC_SEPARATED:
+ {
+ poses[0] = 0; poses[1] = 1; poses[2] = 2; poses[3] = 3; poses[4] = 4;
+ postprocessor = new KisTIFFPostProcessor(nbcolorsamples);
+ }
+ break;
+ default:
+ break;
+ }
+
+
+ // Initisalize tiffReader
+ uint16 * lineSizeCoeffs = new uint16[nbchannels];
+ uint16 vsubsampling = 1;
+ uint16 hsubsampling = 1;
+ for(uint i = 0; i < nbchannels; i++)
+ {
+ lineSizeCoeffs[i] = 1;
+ }
+ if( color_type == PHOTOMETRIC_PALETTE)
+ {
+ uint16 *red; // No need to free them they are free by libtiff
+ uint16 *green;
+ uint16 *blue;
+ if ((TIFFGetField(image, TIFFTAG_COLORMAP, &red, &green, &blue)) == 0)
+ {
+ kdDebug(41008) << "Indexed image does not define a palette" << endl;
+ TIFFClose(image);
+ return KisImageBuilder_RESULT_INVALID_ARG;
+ }
+
+ tiffReader = new KisTIFFReaderFromPalette( layer->paintDevice(), red, green, blue, poses, alphapos, depth, nbcolorsamples, extrasamplescount, transform, postprocessor);
+ } else if(color_type == PHOTOMETRIC_YCBCR ) {
+ TIFFGetFieldDefaulted( image, TIFFTAG_YCBCRSUBSAMPLING, &hsubsampling, &vsubsampling );
+ lineSizeCoeffs[1] = hsubsampling;
+ lineSizeCoeffs[2] = hsubsampling;
+ uint16 position;
+ TIFFGetFieldDefaulted( image, TIFFTAG_YCBCRPOSITIONING, &position );
+ if( dstDepth == 8 )
+ {
+ tiffReader = new KisTIFFYCbCrReaderTarget8Bit(layer->paintDevice(), poses, alphapos, depth, nbcolorsamples, extrasamplescount, transform, postprocessor, hsubsampling, vsubsampling, (KisTIFFYCbCr::Position)position);
+ } else if( dstDepth == 16 )
+ {
+ tiffReader = new KisTIFFYCbCrReaderTarget16Bit( layer->paintDevice(), poses, alphapos, depth, nbcolorsamples, extrasamplescount, transform, postprocessor, hsubsampling, vsubsampling, (KisTIFFYCbCr::Position)position);
+ }
+ } else if(dstDepth == 8)
+ {
+ tiffReader = new KisTIFFReaderTarget8bit( layer->paintDevice(), poses, alphapos, depth, nbcolorsamples, extrasamplescount, transform, postprocessor);
+ } else if(dstDepth == 16) {
+ tiffReader = new KisTIFFReaderTarget16bit( layer->paintDevice(), poses, alphapos, depth, nbcolorsamples, extrasamplescount, transform, postprocessor);
+ } else if(dstDepth == 32) {
+ tiffReader = new KisTIFFReaderTarget32bit( layer->paintDevice(), poses, alphapos, depth, nbcolorsamples, extrasamplescount, transform, postprocessor);
+ }
+
+ if(TIFFIsTiled(image))
+ {
+ kdDebug(41008) << "tiled image" << endl;
+ uint32 tileWidth, tileHeight;
+ uint32 x, y;
+ TIFFGetField(image, TIFFTAG_TILEWIDTH, &tileWidth);
+ TIFFGetField(image, TIFFTAG_TILELENGTH, &tileHeight);
+ uint32 linewidth = (tileWidth * depth * nbchannels) / 8;
+ if(planarconfig == PLANARCONFIG_CONTIG)
+ {
+ buf = _TIFFmalloc(TIFFTileSize(image));
+ if(depth < 16)
+ {
+ tiffstream = new TIFFStreamContigBelow16((uint8*)buf, depth, linewidth);
+ } else if(depth < 32)
+ {
+ tiffstream = new TIFFStreamContigBelow32((uint8*)buf, depth, linewidth);
+ } else {
+ tiffstream = new TIFFStreamContigAbove32((uint8*)buf, depth, linewidth);
+ }
+ } else {
+ ps_buf = new tdata_t[nbchannels];
+ uint32 * lineSizes = new uint32[nbchannels];
+ uint16 baseSize = TIFFTileSize(image)/nbchannels;
+ for(uint i = 0; i < nbchannels; i++)
+ {
+ ps_buf[i] = _TIFFmalloc(baseSize);
+ lineSizes[i] = baseSize / lineSizeCoeffs[i];
+ }
+ tiffstream = new TIFFStreamSeperate( (uint8**) ps_buf, nbchannels, depth, lineSizes);
+ delete [] lineSizes;
+ }
+ kdDebug(41008) << linewidth << " " << nbchannels << " " << layer->paintDevice()->colorSpace()->nColorChannels() << endl;
+ for (y = 0; y < height; y+= tileHeight)
+ {
+ for (x = 0; x < width; x += tileWidth)
+ {
+ kdDebug(41008) << "Reading tile x = " << x << " y = " << y << endl;
+ if( planarconfig == PLANARCONFIG_CONTIG )
+ {
+ TIFFReadTile(image, buf, x, y, 0, (tsample_t) -1);
+ } else {
+ for(uint i = 0; i < nbchannels; i++)
+ {
+ TIFFReadTile(image, ps_buf[i], x, y, 0, i);
+ }
+ }
+ uint32 realTileWidth = (x + tileWidth) < width ? tileWidth : width - x;
+ for (uint yintile = 0; y + yintile < height && yintile < tileHeight/vsubsampling; ) {
+ tiffReader->copyDataToChannels( x, y + yintile , realTileWidth, tiffstream);
+ yintile += 1;
+ tiffstream->moveToLine( yintile );
+ }
+ tiffstream->restart();
+ }
+ }
+ } else {
+ kdDebug(41008) << "striped image" << endl;
+ tsize_t stripsize = TIFFStripSize(image);
+ uint32 rowsPerStrip;
+ TIFFGetFieldDefaulted(image, TIFFTAG_ROWSPERSTRIP, &rowsPerStrip);
+ kdDebug() << rowsPerStrip << " " << height << endl;
+ rowsPerStrip = TQMIN(rowsPerStrip, height); // when TIFFNumberOfStrips(image) == 1 it might happen that rowsPerStrip is incorrectly set
+ if(planarconfig == PLANARCONFIG_CONTIG)
+ {
+ buf = _TIFFmalloc(stripsize);
+ if(depth < 16)
+ {
+ tiffstream = new TIFFStreamContigBelow16((uint8*)buf, depth, stripsize/rowsPerStrip);
+ } else if(depth < 32)
+ {
+ tiffstream = new TIFFStreamContigBelow32((uint8*)buf, depth, stripsize/rowsPerStrip);
+ } else {
+ tiffstream = new TIFFStreamContigAbove32((uint8*)buf, depth, stripsize/rowsPerStrip);
+ }
+ } else {
+ ps_buf = new tdata_t[nbchannels];
+ uint32 scanLineSize = stripsize/rowsPerStrip;
+ kdDebug(41008) << " scanLineSize for each plan = " << scanLineSize << endl;
+ uint32 * lineSizes = new uint32[nbchannels];
+ for(uint i = 0; i < nbchannels; i++)
+ {
+ ps_buf[i] = _TIFFmalloc(stripsize);
+ lineSizes[i] = scanLineSize / lineSizeCoeffs[i];
+ }
+ tiffstream = new TIFFStreamSeperate( (uint8**) ps_buf, nbchannels, depth, lineSizes);
+ delete [] lineSizes;
+ }
+
+ kdDebug(41008) << "Scanline size = " << TIFFRasterScanlineSize(image) << " / strip size = " << TIFFStripSize(image) << " / rowsPerStrip = " << rowsPerStrip << " stripsize/rowsPerStrip = " << stripsize/rowsPerStrip << endl;
+ uint32 y = 0;
+ kdDebug(41008) << " NbOfStrips = " << TIFFNumberOfStrips(image) << " rowsPerStrip = " << rowsPerStrip << " stripsize = " << stripsize << endl;
+ for (uint32 strip = 0; y < height; strip++)
+ {
+ if( planarconfig == PLANARCONFIG_CONTIG )
+ {
+ TIFFReadEncodedStrip(image, TIFFComputeStrip( image, y, 0 ) , buf, (tsize_t) -1);
+ } else {
+ for(uint i = 0; i < nbchannels; i++)
+ {
+ TIFFReadEncodedStrip(image, TIFFComputeStrip( image, y, i ), ps_buf[i], (tsize_t) -1);
+ }
+ }
+ for( uint32 yinstrip = 0 ; yinstrip < rowsPerStrip && y < height ; )
+ {
+ uint linesread = tiffReader->copyDataToChannels( 0, y, width, tiffstream);
+ y += linesread;
+ yinstrip += linesread;
+ tiffstream->moveToLine( yinstrip );
+ }
+ tiffstream->restart();
+ }
+ }
+ tiffReader->finalize();
+ delete lineSizeCoeffs;
+ delete tiffReader;
+ delete tiffstream;
+ if( planarconfig == PLANARCONFIG_CONTIG )
+ {
+ _TIFFfree(buf);
+ } else {
+ for(uint i = 0; i < nbchannels; i++)
+ {
+ _TIFFfree(ps_buf[i]);
+ }
+ delete[] ps_buf;
+ }
+
+ m_img->addLayer(layer, m_img->rootLayer(), 0);
+ return KisImageBuilder_RESULT_OK;
+}
+
+KisImageBuilder_Result KisTIFFConverter::buildImage(const KURL& uri)
+{
+ if (uri.isEmpty())
+ return KisImageBuilder_RESULT_NO_URI;
+
+ if (!KIO::NetAccess::exists(uri, false, tqApp -> mainWidget())) {
+ return KisImageBuilder_RESULT_NOT_EXIST;
+ }
+
+ // We're not set up to handle asynchronous loading at the moment.
+ KisImageBuilder_Result result = KisImageBuilder_RESULT_FAILURE;
+ TQString tmpFile;
+
+ if (KIO::NetAccess::download(uri, tmpFile, tqApp -> mainWidget())) {
+ KURL uriTF;
+ uriTF.setPath( tmpFile );
+ result = decode(uriTF);
+ KIO::NetAccess::removeTempFile(tmpFile);
+ }
+
+ return result;
+}
+
+
+KisImageSP KisTIFFConverter::image()
+{
+ return m_img;
+}
+
+
+KisImageBuilder_Result KisTIFFConverter::buildFile(const KURL& uri, KisImageSP img, KisTIFFOptions options)
+{
+ kdDebug(41008) << "Start writing TIFF File" << endl;
+ if (!img)
+ return KisImageBuilder_RESULT_EMPTY;
+
+ if (uri.isEmpty())
+ return KisImageBuilder_RESULT_NO_URI;
+
+ if (!uri.isLocalFile())
+ return KisImageBuilder_RESULT_NOT_LOCAL;
+
+ // Open file for writing
+ TIFF *image;
+ if((image = TIFFOpen(TQFile::encodeName(uri.path()), "w")) == NULL){
+ kdDebug(41008) << "Could not open the file for writting " << uri.path() << endl;
+ TIFFClose(image);
+ return (KisImageBuilder_RESULT_FAILURE);
+ }
+
+ // Set the document informations
+ KoDocumentInfo * info = m_doc->documentInfo();
+ KoDocumentInfoAbout * aboutPage = static_cast<KoDocumentInfoAbout *>(info->page( "about" ));
+ TQString title = aboutPage->title();
+ if(!title.isEmpty())
+ {
+ TIFFSetField(image, TIFFTAG_DOCUMENTNAME, title.ascii());
+ }
+ TQString abstract = aboutPage->abstract();
+ if(!abstract.isEmpty())
+ {
+ TIFFSetField(image, TIFFTAG_IMAGEDESCRIPTION, abstract.ascii());
+ }
+ KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
+ TQString author = authorPage->fullName();
+ if(!author.isEmpty())
+ {
+ TIFFSetField(image, TIFFTAG_ARTIST, author.ascii());
+ }
+
+ KisTIFFWriterVisitor* visitor = new KisTIFFWriterVisitor(image, &options);
+ KisGroupLayer* root = dynamic_cast<KisGroupLayer*>(img->rootLayer().data());
+ if(root == 0)
+ {
+ KIO::del(uri);
+ TIFFClose(image);
+ return KisImageBuilder_RESULT_FAILURE;
+ }
+ if(!visitor->visit( root ))
+ {
+ KIO::del(uri);
+ TIFFClose(image);
+ return KisImageBuilder_RESULT_FAILURE;
+ }
+
+ TIFFClose(image);
+ return KisImageBuilder_RESULT_OK;
+}
+
+
+void KisTIFFConverter::cancel()
+{
+ m_stop = true;
+}
+
+#include "kis_tiff_converter.moc"
diff --git a/filters/chalk/tiff/kis_tiff_converter.h b/filters/chalk/tiff/kis_tiff_converter.h
new file mode 100644
index 00000000..7d7176b7
--- /dev/null
+++ b/filters/chalk/tiff/kis_tiff_converter.h
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2005-2006 Cyrille Berger <[email protected]>
+ *
+ * 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_TIFF_CONVERTER_H_
+#define _KIS_TIFF_CONVERTER_H_
+
+#include <stdio.h>
+#include <tiffio.h>
+
+#include <tqvaluevector.h>
+
+#include <kio/job.h>
+
+#include <kis_progress_subject.h>
+
+#include "kis_types.h"
+#include "kis_global.h"
+#include "kis_annotation.h"
+class KisDoc;
+class KisUndoAdapter;
+
+/**
+ * Image import/export plugins can use these results to report about success or failure.
+ */
+enum KisImageBuilder_Result {
+ KisImageBuilder_RESULT_FAILURE = -400,
+ KisImageBuilder_RESULT_NOT_EXIST = -300,
+ KisImageBuilder_RESULT_NOT_LOCAL = -200,
+ KisImageBuilder_RESULT_BAD_FETCH = -100,
+ KisImageBuilder_RESULT_INVALID_ARG = -50,
+ KisImageBuilder_RESULT_OK = 0,
+ KisImageBuilder_RESULT_PROGRESS = 1,
+ KisImageBuilder_RESULT_EMPTY = 100,
+ KisImageBuilder_RESULT_BUSY = 150,
+ KisImageBuilder_RESULT_NO_URI = 200,
+ KisImageBuilder_RESULT_UNSUPPORTED = 300,
+ KisImageBuilder_RESULT_INTR = 400,
+ KisImageBuilder_RESULT_PATH = 500,
+ KisImageBuilder_RESULT_UNSUPPORTED_COLORSPACE = 600
+};
+
+struct KisTIFFOptions {
+ TQ_UINT16 compressionType;
+ TQ_UINT16 predictor;
+ bool alpha;
+ bool flatten;
+ TQ_UINT16 jpegQuality;
+ TQ_UINT16 deflateCompress;
+ TQ_UINT16 faxMode;
+ TQ_UINT16 pixarLogCompress;
+};
+
+class KisTIFFConverter : public KisProgressSubject {
+ Q_OBJECT
+ TQ_OBJECT
+ public:
+ KisTIFFConverter(KisDoc *doc, KisUndoAdapter *adapter);
+ virtual ~KisTIFFConverter();
+ public:
+ KisImageBuilder_Result buildImage(const KURL& uri);
+ KisImageBuilder_Result buildFile(const KURL& uri, KisImageSP layer, KisTIFFOptions);
+ /** Retrieve the constructed image
+ */
+ KisImageSP image();
+ public slots:
+ virtual void cancel();
+ private:
+ KisImageBuilder_Result decode(const KURL& uri);
+ KisImageBuilder_Result readTIFFDirectory( TIFF* image);
+ private:
+ KisImageSP m_img;
+ KisDoc *m_doc;
+ KisUndoAdapter *m_adapter;
+ bool m_stop;
+ KIO::TransferJob *m_job;
+};
+
+#endif
diff --git a/filters/chalk/tiff/kis_tiff_export.cc b/filters/chalk/tiff/kis_tiff_export.cc
new file mode 100644
index 00000000..bcd3f22e
--- /dev/null
+++ b/filters/chalk/tiff/kis_tiff_export.cc
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2005 Cyrille Berger <[email protected]>
+ *
+ * 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 "kis_tiff_export.h"
+
+#include <tqcheckbox.h>
+#include <tqslider.h>
+
+#include <kapplication.h>
+#include <kcombobox.h>
+#include <kdialogbase.h>
+#include <kgenericfactory.h>
+
+#include <KoFilterChain.h>
+
+#include <kis_doc.h>
+#include <kis_group_layer.h>
+#include <kis_image.h>
+#include <kis_paint_layer.h>
+#include <kis_progress_display_interface.h>
+
+#include "kis_tiff_converter.h"
+#include "kis_dlg_options_tiff.h"
+#include "kis_wdg_options_tiff.h"
+
+typedef KGenericFactory<KisTIFFExport, KoFilter> KisTIFFExportFactory;
+K_EXPORT_COMPONENT_FACTORY(libchalktiffexport, KisTIFFExportFactory("kofficefilters"))
+
+KisTIFFExport::KisTIFFExport(KoFilter *, const char *, const TQStringList&) : KoFilter()
+{
+}
+
+KisTIFFExport::~KisTIFFExport()
+{
+}
+
+KoFilter::ConversiontqStatus KisTIFFExport::convert(const TQCString& from, const TQCString& to)
+{
+ kdDebug(41008) << "Tiff export! From: " << from << ", To: " << to << "\n";
+
+ if (from != "application/x-chalk")
+ return KoFilter::NotImplemented;
+
+
+ KisDlgOptionsTIFF* kdb = new KisDlgOptionsTIFF(0, "options dialog for tiff");
+
+ KisDoc *output = dynamic_cast<KisDoc*>(m_chain->inputDocument());
+
+ KisColorSpace* cs = output->currentImage()->colorSpace();
+ KisChannelInfo::enumChannelValueType type = cs->channels()[0]->channelValueType();
+ if( type == KisChannelInfo::FLOAT16 || type == KisChannelInfo::FLOAT32)
+ {
+ kdb->optionswdg->kComboBoxPredictor->removeItem(1);
+ } else {
+ kdb->optionswdg->kComboBoxPredictor->removeItem(2);
+ }
+
+ if(kdb->exec() == TQDialog::Rejected)
+ {
+ return KoFilter::OK; // FIXME Cancel doesn't exist :(
+ }
+
+ KisTIFFOptions options = kdb->options();
+
+ if( ( type == KisChannelInfo::FLOAT16 || type == KisChannelInfo::FLOAT32) && options.predictor == 2 )
+ { // FIXME THIS IS AN HACK FIX THAT IN 2.0 !!
+ options.predictor = 3;
+ }
+ delete kdb;
+
+ TQString filename = m_chain->outputFile();
+
+ if (!output)
+ return KoFilter::CreationError;
+
+ if (filename.isEmpty()) return KoFilter::FileNotFound;
+
+ KURL url;
+ url.setPath(filename);
+
+ KisImageSP img;
+
+ if(options.flatten)
+ {
+ img = new KisImage(0, output->currentImage()->width(), output->currentImage()->height(), output->currentImage()->colorSpace(), "");
+ KisPaintDeviceSP pd = new KisPaintDevice(*output->currentImage()->projection());
+ KisPaintLayerSP l = new KisPaintLayer(img, "projection", OPACITY_OPAQUE, pd);
+ img->addLayer(l.data(), img->rootLayer(), 0);
+ } else {
+ img = output->currentImage();
+ }
+
+
+ KisTIFFConverter ktc(output, output->undoAdapter());
+/* vKisAnnotationSP_it beginIt = img->beginAnnotations();
+ vKisAnnotationSP_it endIt = img->endAnnotations();*/
+ KisImageBuilder_Result res;
+ if ( (res = ktc.buildFile(url, img, options)) == KisImageBuilder_RESULT_OK) {
+ kdDebug(41008) << "success !" << endl;
+ return KoFilter::OK;
+ }
+ kdDebug(41008) << " Result = " << res << endl;
+ return KoFilter::InternalError;
+}
+
+#include <kis_tiff_export.moc>
+
diff --git a/filters/chalk/tiff/kis_tiff_export.h b/filters/chalk/tiff/kis_tiff_export.h
new file mode 100644
index 00000000..113747c7
--- /dev/null
+++ b/filters/chalk/tiff/kis_tiff_export.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2005 Cyrille Berger <[email protected]>
+ *
+ * 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_TIFF_EXPORT_H_
+#define _KIS_TIFF_EXPORT_H_
+
+#include <KoFilter.h>
+
+class KisTIFFExport : public KoFilter {
+ Q_OBJECT
+ TQ_OBJECT
+ public:
+ KisTIFFExport(KoFilter *tqparent, const char *name, const TQStringList&);
+ virtual ~KisTIFFExport();
+ public:
+ virtual KoFilter::ConversiontqStatus convert(const TQCString& from, const TQCString& to);
+};
+
+#endif
diff --git a/filters/chalk/tiff/kis_tiff_import.cc b/filters/chalk/tiff/kis_tiff_import.cc
new file mode 100644
index 00000000..89d1763f
--- /dev/null
+++ b/filters/chalk/tiff/kis_tiff_import.cc
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2005 Cyrille Berger <[email protected]>
+ *
+ * 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 "kis_tiff_import.h"
+
+#include <kgenericfactory.h>
+
+#include <KoFilterChain.h>
+
+#include <kis_doc.h>
+#include <kis_image.h>
+#include <kis_progress_display_interface.h>
+#include <kis_view.h>
+
+#include "kis_tiff_converter.h"
+
+typedef KGenericFactory<KisTIFFImport, KoFilter> TIFFImportFactory;
+K_EXPORT_COMPONENT_FACTORY(libchalktiffimport, TIFFImportFactory("kofficefilters"))
+
+KisTIFFImport::KisTIFFImport(KoFilter *, const char *, const TQStringList&) : KoFilter()
+{
+}
+
+KisTIFFImport::~KisTIFFImport()
+{
+}
+
+KoFilter::ConversiontqStatus KisTIFFImport::convert(const TQCString&, const TQCString& to)
+{
+ kdDebug(41008) << "Importing using TIFFImport!\n";
+
+ if (to != "application/x-chalk")
+ return KoFilter::BadMimeType;
+
+ KisDoc * doc = dynamic_cast<KisDoc*>(m_chain -> outputDocument());
+ KisView * view = static_cast<KisView*>(doc -> views().getFirst());
+
+ TQString filename = m_chain -> inputFile();
+
+ if (!doc)
+ return KoFilter::CreationError;
+
+ doc -> prepareForImport();
+
+
+ if (!filename.isEmpty()) {
+
+ KURL url;
+ url.setPath(filename);
+
+ if (url.isEmpty())
+ return KoFilter::FileNotFound;
+
+ KisTIFFConverter ib(doc, doc -> undoAdapter());
+
+ if (view != 0)
+ view -> canvasSubject() -> progressDisplay() -> setSubject(&ib, false, true);
+
+ switch (ib.buildImage(url)) {
+ case KisImageBuilder_RESULT_UNSUPPORTED:
+ return KoFilter::NotImplemented;
+ break;
+ case KisImageBuilder_RESULT_INVALID_ARG:
+ return KoFilter::BadMimeType;
+ break;
+ case KisImageBuilder_RESULT_NO_URI:
+ case KisImageBuilder_RESULT_NOT_LOCAL:
+ return KoFilter::FileNotFound;
+ break;
+ case KisImageBuilder_RESULT_BAD_FETCH:
+ case KisImageBuilder_RESULT_EMPTY:
+ return KoFilter::ParsingError;
+ break;
+ case KisImageBuilder_RESULT_FAILURE:
+ return KoFilter::InternalError;
+ break;
+ case KisImageBuilder_RESULT_OK:
+ doc -> setCurrentImage( ib.image());
+ return KoFilter::OK;
+ default:
+ break;
+ }
+
+ }
+ return KoFilter::StorageCreationError;
+}
+
+#include <kis_tiff_import.moc>
+
diff --git a/filters/chalk/tiff/kis_tiff_import.h b/filters/chalk/tiff/kis_tiff_import.h
new file mode 100644
index 00000000..9fef7755
--- /dev/null
+++ b/filters/chalk/tiff/kis_tiff_import.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2005 Cyrille Berger <[email protected]>
+ *
+ * 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_TIFF_IMPORT_H_
+#define _KIS_TIFF_IMPORT_H_
+
+#include <KoFilter.h>
+
+class KisTIFFImport : public KoFilter {
+ Q_OBJECT
+ TQ_OBJECT
+ public:
+ KisTIFFImport(KoFilter *tqparent, const char *name, const TQStringList&);
+ virtual ~KisTIFFImport();
+ public:
+ virtual KoFilter::ConversiontqStatus convert(const TQCString& from, const TQCString& to);
+};
+
+#endif
diff --git a/filters/chalk/tiff/kis_tiff_reader.cc b/filters/chalk/tiff/kis_tiff_reader.cc
new file mode 100644
index 00000000..f2eabd87
--- /dev/null
+++ b/filters/chalk/tiff/kis_tiff_reader.cc
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2005-2006 Cyrille Berger <[email protected]>
+ *
+ * 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 "kis_tiff_reader.h"
+
+#include <kdebug.h>
+
+#include <kis_iterators_pixel.h>
+#include <kis_paint_device.h>
+
+#include "kis_tiff_stream.h"
+
+ uint KisTIFFReaderTarget8bit::copyDataToChannels( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 dataWidth, TIFFStreamBase* tiffstream)
+ {
+ KisHLineIterator it = paintDevice() -> createHLineIterator(x, y, dataWidth, true);
+ double coeff = TQ_UINT8_MAX / (double)( pow(2, sourceDepth() ) - 1 );
+// kdDebug(41008) << " depth expension coefficient : " << coeff << endl;
+ while (!it.isDone()) {
+ TQ_UINT8 *d = it.rawData();
+ TQ_UINT8 i;
+ for(i = 0; i < nbColorsSamples() ; i++)
+ {
+ d[poses()[i]] = (TQ_UINT8)( tiffstream->nextValue() * coeff );
+ }
+ postProcessor()->postProcess8bit( d);
+ if(transform()) cmsDoTransform(transform(), d, d, 1);
+ d[poses()[i]] = TQ_UINT8_MAX;
+ for(int k = 0; k < nbExtraSamples(); k++)
+ {
+ if(k == alphaPos())
+ d[poses()[i]] = (TQ_UINT32) ( tiffstream->nextValue() * coeff );
+ else
+ tiffstream->nextValue();
+ }
+ ++it;
+ }
+ return 1;
+ }
+ uint KisTIFFReaderTarget16bit::copyDataToChannels( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 dataWidth, TIFFStreamBase* tiffstream)
+ {
+ KisHLineIterator it = paintDevice() -> createHLineIterator(x, y, dataWidth, true);
+ double coeff = TQ_UINT16_MAX / (double)( pow(2, sourceDepth() ) - 1 );
+// kdDebug(41008) << " depth expension coefficient : " << coeff << endl;
+ while (!it.isDone()) {
+ TQ_UINT16 *d = reinterpret_cast<TQ_UINT16 *>(it.rawData());
+ TQ_UINT8 i;
+ for(i = 0; i < nbColorsSamples(); i++)
+ {
+ d[poses()[i]] = (TQ_UINT16)( tiffstream->nextValue() * coeff );
+ }
+ postProcessor()->postProcess16bit( d);
+ if(transform()) cmsDoTransform(transform(), d, d, 1);
+ d[poses()[i]] = TQ_UINT16_MAX;
+ for(int k = 0; k < nbExtraSamples(); k++)
+ {
+ if(k == alphaPos())
+ d[poses()[i]] = (TQ_UINT16) ( tiffstream->nextValue() * coeff );
+ else
+ tiffstream->nextValue();
+ }
+ ++it;
+ }
+ return 1;
+ }
+
+ uint KisTIFFReaderTarget32bit::copyDataToChannels( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 dataWidth, TIFFStreamBase* tiffstream)
+ {
+ KisHLineIterator it = paintDevice() -> createHLineIterator(x, y, dataWidth, true);
+ double coeff = TQ_UINT32_MAX / (double)( pow(2, sourceDepth() ) - 1 );
+// kdDebug(41008) << " depth expension coefficient : " << coeff << endl;
+ while (!it.isDone()) {
+ TQ_UINT32 *d = reinterpret_cast<TQ_UINT32 *>(it.rawData());
+ TQ_UINT8 i;
+ for(i = 0; i < nbColorsSamples(); i++)
+ {
+ d[poses()[i]] = (TQ_UINT32)( tiffstream->nextValue() * coeff );
+ }
+ postProcessor()->postProcess32bit( d);
+ if(transform()) cmsDoTransform(transform(), d, d, 1);
+ d[poses()[i]] = TQ_UINT32_MAX;
+ for(int k = 0; k < nbExtraSamples(); k++)
+ {
+ if(k == alphaPos())
+ d[poses()[i]] = (TQ_UINT32) ( tiffstream->nextValue() * coeff );
+ else
+ tiffstream->nextValue();
+ }
+ ++it;
+ }
+ return 1;
+ }
+ uint KisTIFFReaderFromPalette::copyDataToChannels(TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 dataWidth, TIFFStreamBase* tiffstream)
+ {
+ KisHLineIterator it = paintDevice() -> createHLineIterator(x, y, dataWidth, true);
+ while (!it.isDone()) {
+ TQ_UINT16* d = reinterpret_cast<TQ_UINT16 *>(it.rawData());
+ uint32 index = tiffstream->nextValue();
+ d[2] = m_red[index];
+ d[1] = m_green[index];
+ d[0] = m_blue[index];
+ d[3] = TQ_UINT16_MAX;
+ ++it;
+ }
+ return 1;
+ }
diff --git a/filters/chalk/tiff/kis_tiff_reader.h b/filters/chalk/tiff/kis_tiff_reader.h
new file mode 100644
index 00000000..2ab573dd
--- /dev/null
+++ b/filters/chalk/tiff/kis_tiff_reader.h
@@ -0,0 +1,206 @@
+/*
+ * Copyright (c) 2006 Cyrille Berger <[email protected]>
+ *
+ * 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_TIFF_READER_H_
+#define _KIS_TIFF_READER_H_
+
+// On some platforms, tiffio.h #defines NULL in a bad
+// way for C++, as (void *)0 instead of using the correct
+// C++ value 0. Include stdio.h first to get the right one.
+#include <stdio.h>
+#include <tiffio.h>
+
+// #include <tqvaluevector.h>
+// #include <kio/job.h>
+// #include <kis_progress_subject.h>
+
+#include <kis_paint_device.h>
+
+#include "kis_types.h"
+#include "kis_global.h"
+// #include "kis_annotation.h"
+
+#include <kis_iterator.h>
+#include <kis_paint_device.h>
+
+#define TQ_UINT32_MAX 4294967295u
+
+class TIFFStreamBase;
+
+class KisTIFFPostProcessor {
+ public:
+ KisTIFFPostProcessor(uint8 nbcolorssamples) : m_nbcolorssamples(nbcolorssamples) { }
+ public:
+ virtual void postProcess8bit( TQ_UINT8* ) { };
+ virtual void postProcess16bit( TQ_UINT16* ) { };
+ virtual void postProcess32bit( TQ_UINT32* ) { };
+ protected:
+ inline uint8 nbColorsSamples() { return m_nbcolorssamples; }
+ private:
+ uint8 m_nbcolorssamples;
+};
+
+class KisTIFFPostProcessorInvert : public KisTIFFPostProcessor {
+ public:
+ KisTIFFPostProcessorInvert(uint8 nbcolorssamples) : KisTIFFPostProcessor(nbcolorssamples) {}
+ public:
+ virtual void postProcess8bit( TQ_UINT8* data )
+ {
+ for(int i = 0; i < nbColorsSamples(); i++)
+ {
+ data[i] = TQ_UINT8_MAX - data[i];
+ }
+ }
+ virtual void postProcess16bit( TQ_UINT16* data )
+ {
+ TQ_UINT16* d = (TQ_UINT16*) data;
+ for(int i = 0; i < nbColorsSamples(); i++)
+ {
+ d[i] = TQ_UINT16_MAX - d[i];
+ }
+ }
+ virtual void postProcess32bit( TQ_UINT32* data )
+ {
+ TQ_UINT32* d = (TQ_UINT32*) data;
+ for(int i = 0; i < nbColorsSamples(); i++)
+ {
+ d[i] = TQ_UINT32_MAX - d[i];
+ }
+ }
+};
+
+class KisTIFFPostProcessorICCLABtoCIELAB : public KisTIFFPostProcessor {
+ public:
+ KisTIFFPostProcessorICCLABtoCIELAB(uint8 nbcolorssamples) : KisTIFFPostProcessor(nbcolorssamples) {}
+ public:
+ void postProcess8bit(TQ_UINT8* data)
+ {
+ TQ_INT8* ds = (TQ_INT8*) data;
+ for(int i = 1; i < nbColorsSamples(); i++)
+ {
+ ds[i] = data[i] - TQ_UINT8_MAX/2;
+ }
+ }
+ void postProcess16bit(TQ_UINT16* data)
+ {
+ TQ_UINT16* d = (TQ_UINT16*) data;
+ TQ_INT16* ds = (TQ_INT16*) data;
+ for(int i = 1; i < nbColorsSamples(); i++)
+ {
+ ds[i] = d[i] - TQ_UINT16_MAX /2;
+ }
+ }
+ void postProcess32bit(TQ_UINT32* data)
+ {
+ TQ_UINT32* d = (TQ_UINT32*) data;
+ TQ_INT32* ds = (TQ_INT32*) data;
+ for(int i = 1; i < nbColorsSamples(); i++)
+ {
+ ds[i] = d[i] - TQ_UINT32_MAX /2;
+ }
+ }
+};
+
+
+class KisTIFFReaderBase {
+ public:
+ KisTIFFReaderBase( KisPaintDeviceSP device, TQ_UINT8* poses, int8 alphapos, uint8 sourceDepth, uint8 nbcolorssamples, uint8 extrasamplescount, cmsHTRANSFORM transformProfile, KisTIFFPostProcessor* postprocessor) : m_device(device), m_alphapos(alphapos), m_sourceDepth(sourceDepth), m_nbcolorssamples(nbcolorssamples), m_nbextrasamples(extrasamplescount), m_poses(poses), m_transformProfile(transformProfile), m_postprocess(postprocessor)
+ {
+
+ }
+ public:
+ /**
+ * This function copy data from the tiff stream to the paint device starting at the given position.
+ * @param x horizontal start position
+ * @param y vertical start position
+ * @param dataWidth width of the data to copy
+ * @param tiffstream source of data
+ *
+ * @return the number of line which were copied
+ */
+ virtual uint copyDataToChannels( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 dataWidth, TIFFStreamBase* tiffstream) =0;
+ /**
+ * This function is called when all data has been read and should be used for any postprocessing.
+ */
+ virtual void finalize() { };
+ protected:
+ inline KisPaintDeviceSP paintDevice() { return m_device; }
+ inline TQ_UINT8 alphaPos() { return m_alphapos; }
+ inline TQ_UINT8 sourceDepth() { return m_sourceDepth; }
+ inline TQ_UINT8 nbColorsSamples() { return m_nbcolorssamples; }
+ inline TQ_UINT8 nbExtraSamples() { return m_nbextrasamples; }
+ inline TQ_UINT8* poses() { return m_poses; }
+ inline cmsHTRANSFORM transform() { return m_transformProfile; }
+ inline KisTIFFPostProcessor* postProcessor() { return m_postprocess; }
+ private:
+ KisPaintDeviceSP m_device;
+ TQ_UINT8 m_alphapos;
+ TQ_UINT8 m_sourceDepth;
+ TQ_UINT8 m_nbcolorssamples;
+ TQ_UINT8 m_nbextrasamples;
+ TQ_UINT8* m_poses;
+ cmsHTRANSFORM m_transformProfile;
+ KisTIFFPostProcessor* m_postprocess;
+ TQ_UINT32 m_tiffDataWidth;
+};
+
+class KisTIFFReaderTarget8bit : public KisTIFFReaderBase {
+ public:
+ KisTIFFReaderTarget8bit( KisPaintDeviceSP device, TQ_UINT8* poses, int8 alphapos, uint8 sourceDepth, uint8 nbcolorssamples, uint8 extrasamplescount, cmsHTRANSFORM transformProfile, KisTIFFPostProcessor* postprocessor) : KisTIFFReaderBase(device, poses, alphapos, sourceDepth, nbcolorssamples, extrasamplescount, transformProfile, postprocessor )
+ {
+
+ }
+ public:
+ virtual uint copyDataToChannels( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 dataWidth, TIFFStreamBase* tiffstream);
+};
+
+
+class KisTIFFReaderTarget16bit : public KisTIFFReaderBase {
+ public:
+ KisTIFFReaderTarget16bit( KisPaintDeviceSP device, TQ_UINT8* poses, int8 alphapos, uint8 sourceDepth, uint8 nbcolorssamples, uint8 extrasamplescount, cmsHTRANSFORM transformProfile, KisTIFFPostProcessor* postprocessor) : KisTIFFReaderBase(device, poses, alphapos, sourceDepth, nbcolorssamples, extrasamplescount, transformProfile, postprocessor )
+ {
+
+ }
+ public:
+ virtual uint copyDataToChannels( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 dataWidth, TIFFStreamBase* tiffstream) ;
+};
+
+class KisTIFFReaderTarget32bit : public KisTIFFReaderBase {
+ public:
+ KisTIFFReaderTarget32bit( KisPaintDeviceSP device, TQ_UINT8* poses, int8 alphapos, uint8 sourceDepth, uint8 nbcolorssamples, uint8 extrasamplescount, cmsHTRANSFORM transformProfile, KisTIFFPostProcessor* postprocessor) : KisTIFFReaderBase(device, poses, alphapos, sourceDepth, nbcolorssamples, extrasamplescount, transformProfile, postprocessor )
+ {
+
+ }
+ public:
+ virtual uint copyDataToChannels( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 dataWidth, TIFFStreamBase* tiffstream) ;
+};
+
+class KisTIFFReaderFromPalette : public KisTIFFReaderBase {
+ public:
+ KisTIFFReaderFromPalette( KisPaintDeviceSP device, uint16 *red, uint16 *green, uint16 *blue, TQ_UINT8* poses, int8 alphapos, uint8 sourceDepth, uint8 nbcolorssamples, uint8 extrasamplescount, cmsHTRANSFORM transformProfile, KisTIFFPostProcessor* postprocessor) : KisTIFFReaderBase(device, poses, alphapos, sourceDepth, nbcolorssamples, extrasamplescount, transformProfile, postprocessor ), m_red(red), m_green(green), m_blue(blue)
+ {
+
+ }
+ public:
+ virtual uint copyDataToChannels( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 dataWidth, TIFFStreamBase* tiffstream) ;
+ private:
+ uint16 *m_red, *m_green, *m_blue;
+};
+
+#endif
diff --git a/filters/chalk/tiff/kis_tiff_stream.cc b/filters/chalk/tiff/kis_tiff_stream.cc
new file mode 100644
index 00000000..3d52d4dc
--- /dev/null
+++ b/filters/chalk/tiff/kis_tiff_stream.cc
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2005-2006 Cyrille Berger <[email protected]>
+ *
+ * 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 "kis_tiff_stream.h"
+
+TIFFStreamContigBase::TIFFStreamContigBase( uint8* src, uint16 depth, uint32 lineSize ) : TIFFStreamBase(depth), m_src(src), m_lineSize(lineSize) { restart(); }
+
+void TIFFStreamContigBase::restart()
+{
+ m_srcit = m_src;
+ m_posinc = 8;
+}
+
+void TIFFStreamContigBase::moveToLine(uint32 lineNumber)
+{
+ m_srcit = m_src + lineNumber * m_lineSize;
+ m_posinc = 8;
+}
+
+uint32 TIFFStreamContigBelow16::nextValue()
+{
+ register uint8 remain;
+ register uint32 value;
+ remain = m_depth;
+ value = 0;
+ while (remain > 0)
+ {
+ register uint8 toread;
+ toread = remain;
+ if (toread > m_posinc) toread = m_posinc;
+ remain -= toread;
+ m_posinc -= toread;
+ value = (value << toread) | (( (*m_srcit) >> (m_posinc) ) & ( ( 1 << toread ) - 1 ) );
+ if (m_posinc == 0)
+ {
+ m_srcit++;
+ m_posinc=8;
+ }
+ }
+ return value;
+}
+
+uint32 TIFFStreamContigBelow32::nextValue()
+{
+ register uint8 remain;
+ register uint32 value;
+ remain = m_depth;
+ value = 0;
+ while (remain > 0)
+ {
+ register uint8 toread;
+ toread = remain;
+ if (toread > m_posinc) toread = m_posinc;
+ remain -= toread;
+ m_posinc -= toread;
+ value = (value) | ( (( (*m_srcit) >> (m_posinc) ) & ( ( 1 << toread ) - 1 ) ) << ( m_depth - 8 - remain ) );
+ if (m_posinc == 0)
+ {
+ m_srcit++;
+ m_posinc=8;
+ }
+ }
+ return value;
+}
+
+uint32 TIFFStreamContigAbove32::nextValue()
+{
+ register uint8 remain;
+ register uint32 value;
+ remain = m_depth;
+ value = 0;
+ while (remain > 0)
+ {
+ register uint8 toread;
+ toread = remain;
+ if (toread > m_posinc) toread = m_posinc;
+ remain -= toread;
+ m_posinc -= toread;
+ if(remain < 32 )
+ {
+ value = (value) | ( (( (*m_srcit) >> (m_posinc) ) & ( ( 1 << toread ) - 1 ) ) << ( 24 - remain ) );
+ }
+ if (m_posinc == 0)
+ {
+ m_srcit++;
+ m_posinc=8;
+ }
+ }
+ return value;
+}
+
+TIFFStreamSeperate::TIFFStreamSeperate( uint8** srcs, uint8 nb_samples ,uint16 depth, uint32* lineSize) : TIFFStreamBase(depth), m_nb_samples(nb_samples)
+{
+ streams = new TIFFStreamContigBase*[nb_samples];
+ if(depth < 16)
+ {
+ for(uint8 i = 0; i < m_nb_samples; i++)
+ {
+ streams[i] = new TIFFStreamContigBelow16(srcs[i], depth, lineSize[i]);
+ }
+ } else if( depth < 32 )
+ {
+ for(uint8 i = 0; i < m_nb_samples; i++)
+ {
+ streams[i] = new TIFFStreamContigBelow32(srcs[i], depth, lineSize[i]);
+ }
+ } else {
+ for(uint8 i = 0; i < m_nb_samples; i++)
+ {
+ streams[i] = new TIFFStreamContigAbove32(srcs[i], depth, lineSize[i]);
+ }
+ }
+ restart();
+}
+
+TIFFStreamSeperate::~TIFFStreamSeperate()
+{
+ for(uint8 i = 0; i < m_nb_samples; i++)
+ {
+ delete streams[i];
+ }
+ delete[] streams;
+}
+
+uint32 TIFFStreamSeperate::nextValue()
+{
+ uint32 value = streams[ m_current_sample ]->nextValue();
+ if( (++m_current_sample) >= m_nb_samples)
+ m_current_sample = 0;
+ return value;
+}
+
+void TIFFStreamSeperate::restart()
+{
+ m_current_sample = 0;
+ for(uint8 i = 0; i < m_nb_samples; i++)
+ {
+ streams[i]->restart();
+ }
+}
+
+void TIFFStreamSeperate::moveToLine(uint32 lineNumber)
+{
+ for(uint8 i = 0; i < m_nb_samples; i++)
+ {
+ streams[i]->moveToLine(lineNumber);
+ }
+}
diff --git a/filters/chalk/tiff/kis_tiff_stream.h b/filters/chalk/tiff/kis_tiff_stream.h
new file mode 100644
index 00000000..f203568e
--- /dev/null
+++ b/filters/chalk/tiff/kis_tiff_stream.h
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2005-2006 Cyrille Berger <[email protected]>
+ *
+ * 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 TIFFSTREAM_H_
+#define TIFFSTREAM_H_
+
+#include <tiffio.h>
+
+class TIFFStreamBase {
+ public:
+ TIFFStreamBase( uint16 depth ) : m_depth(depth) {};
+ virtual uint32 nextValue() =0;
+ virtual void restart() =0;
+ virtual void moveToLine(uint32 lineNumber) =0;
+ protected:
+ uint16 m_depth;
+};
+
+class TIFFStreamContigBase : public TIFFStreamBase {
+ public:
+ TIFFStreamContigBase( uint8* src, uint16 depth, uint32 lineSize );
+ virtual void restart();
+ virtual void moveToLine(uint32 lineNumber);
+ protected:
+ uint8* m_src;
+ uint8* m_srcit;
+ uint8 m_posinc;
+ uint32 m_lineSize;
+};
+
+class TIFFStreamContigBelow16 : public TIFFStreamContigBase {
+ public:
+ TIFFStreamContigBelow16( uint8* src, uint16 depth, uint32 lineSize ) : TIFFStreamContigBase(src, depth, lineSize) { }
+ public:
+ virtual uint32 nextValue();
+};
+
+class TIFFStreamContigBelow32 : public TIFFStreamContigBase {
+ public:
+ TIFFStreamContigBelow32( uint8* src, uint16 depth, uint32 lineSize ) : TIFFStreamContigBase(src, depth, lineSize) { }
+ public:
+ virtual uint32 nextValue();
+};
+
+class TIFFStreamContigAbove32 : public TIFFStreamContigBase {
+ public:
+ TIFFStreamContigAbove32( uint8* src, uint16 depth, uint32 lineSize ) : TIFFStreamContigBase(src, depth, lineSize) { }
+ public:
+ virtual uint32 nextValue();
+};
+
+
+class TIFFStreamSeperate : public TIFFStreamBase {
+ public:
+ TIFFStreamSeperate( uint8** srcs, uint8 nb_samples ,uint16 depth, uint32* lineSize);
+ ~TIFFStreamSeperate();
+ virtual uint32 nextValue();
+ virtual void restart();
+ virtual void moveToLine(uint32 lineNumber);
+ private:
+ TIFFStreamContigBase** streams;
+ uint8 m_current_sample, m_nb_samples;
+};
+
+#endif
diff --git a/filters/chalk/tiff/kis_tiff_writer_visitor.cpp b/filters/chalk/tiff/kis_tiff_writer_visitor.cpp
new file mode 100644
index 00000000..681e66b7
--- /dev/null
+++ b/filters/chalk/tiff/kis_tiff_writer_visitor.cpp
@@ -0,0 +1,237 @@
+/*
+ * Copyright (c) 2006 Cyrille Berger <[email protected]>
+ *
+ * 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 "kis_tiff_writer_visitor.h"
+
+#include <kmessagebox.h>
+#include <klocale.h>
+
+#include <kis_annotation.h>
+#include <kis_colorspace.h>
+#include <kis_group_layer.h>
+#include <kis_image.h>
+#include <kis_paint_layer.h>
+#include <kis_types.h>
+
+#include "kis_tiff_converter.h"
+
+namespace {
+ bool writeColorSpaceInformation( TIFF* image, KisColorSpace * cs, uint16& color_type, uint16& sample_format )
+ {
+ sample_format = SAMPLEFORMAT_UINT;
+ if ( cs->id() == KisID("GRAYA") || cs->id() == KisID("GRAYA16") )
+ {
+ color_type = PHOTOMETRIC_MINISBLACK;
+ return true;
+ }
+ if ( cs->id() == KisID("RGBA") || cs->id() == KisID("RGBA16") )
+ {
+ color_type = PHOTOMETRIC_RGB;
+ return true;
+ }
+ if ( cs->id() == KisID("RGBAF16HALF") || cs->id() == KisID("RGBAF32") )
+ {
+ color_type = PHOTOMETRIC_RGB;
+ sample_format = SAMPLEFORMAT_IEEEFP;
+ return true;
+ }
+ if ( cs->id() == KisID("CMYK") || cs->id() == KisID("CMYKA16") )
+ {
+ color_type = PHOTOMETRIC_SEPARATED;
+ TIFFSetField(image, TIFFTAG_INKSET, INKSET_CMYK);
+ return true;
+ }
+ if ( cs->id() == KisID("LABA") )
+ {
+ color_type = PHOTOMETRIC_CIELAB;
+ return true;
+ }
+
+ KMessageBox::error(0, i18n("Cannot export images in %1.\n").tqarg(cs->id().name()) ) ;
+ return false;
+
+ }
+}
+
+KisTIFFWriterVisitor::KisTIFFWriterVisitor(TIFF*img, KisTIFFOptions* options) : m_image(img), m_options(options)
+{
+}
+
+KisTIFFWriterVisitor::~KisTIFFWriterVisitor()
+{
+}
+
+bool KisTIFFWriterVisitor::saveAlpha() { return m_options->alpha; }
+
+bool KisTIFFWriterVisitor::copyDataToStrips( KisHLineIterator it, tdata_t buff, uint8 depth, uint8 nbcolorssamples, TQ_UINT8* poses)
+{
+ if(depth == 32)
+ {
+ TQ_UINT32 *dst = reinterpret_cast<TQ_UINT32 *>(buff);
+ while (!it.isDone()) {
+ const TQ_UINT32 *d = reinterpret_cast<const TQ_UINT32 *>(it.rawData());
+ int i;
+ for(i = 0; i < nbcolorssamples; i++)
+ {
+ *(dst++) = d[poses[i]];
+ }
+ if(saveAlpha()) *(dst++) = d[poses[i]];
+ ++it;
+ }
+ return true;
+ } else if(depth == 16)
+ {
+ TQ_UINT16 *dst = reinterpret_cast<TQ_UINT16 *>(buff);
+ while (!it.isDone()) {
+ const TQ_UINT16 *d = reinterpret_cast<const TQ_UINT16 *>(it.rawData());
+ int i;
+ for(i = 0; i < nbcolorssamples; i++)
+ {
+ *(dst++) = d[poses[i]];
+ }
+ if(saveAlpha()) *(dst++) = d[poses[i]];
+ ++it;
+ }
+ return true;
+ } else if(depth == 8) {
+ TQ_UINT8 *dst = reinterpret_cast<TQ_UINT8 *>(buff);
+ while (!it.isDone()) {
+ const TQ_UINT8 *d = it.rawData();
+ int i;
+ for(i = 0; i < nbcolorssamples; i++)
+ {
+ *(dst++) = d[poses[i]];
+ }
+ if(saveAlpha()) *(dst++) = d[poses[i]];
+ ++it;
+ }
+ return true;
+ }
+ return false;
+}
+
+
+bool KisTIFFWriterVisitor::visit(KisPaintLayer *layer)
+{
+ kdDebug(41008) << "visiting on paint layer " << layer->name() << "\n";
+ KisPaintDeviceSP pd = layer->paintDevice();
+ // Save depth
+ int depth = 8 * pd->pixelSize() / pd->nChannels();
+ TIFFSetField(image(), TIFFTAG_BITSPERSAMPLE, depth);
+ // Save number of samples
+ if(saveAlpha())
+ {
+ TIFFSetField(image(), TIFFTAG_SAMPLESPERPIXEL, pd->nChannels());
+ uint16 sampleinfo[1] = { EXTRASAMPLE_UNASSALPHA };
+ TIFFSetField(image(), TIFFTAG_EXTRASAMPLES, 1, sampleinfo);
+ } else {
+ TIFFSetField(image(), TIFFTAG_SAMPLESPERPIXEL, pd->nChannels() - 1);
+ TIFFSetField(image(), TIFFTAG_EXTRASAMPLES, 0);
+ }
+ // Save colorspace information
+ uint16 color_type;
+ uint16 sample_format;
+ if(!writeColorSpaceInformation(image(), pd->colorSpace(), color_type, sample_format))
+ { // unsupported colorspace
+ return false;
+ }
+ TIFFSetField(image(), TIFFTAG_PHOTOMETRIC, color_type);
+ TIFFSetField(image(), TIFFTAG_SAMPLEFORMAT, sample_format);
+ TIFFSetField(image(), TIFFTAG_IMAGEWIDTH, layer->image()->width());
+ TIFFSetField(image(), TIFFTAG_IMAGELENGTH, layer->image()->height());
+
+ // Set the compression options
+ TIFFSetField(image(), TIFFTAG_COMPRESSION, m_options->compressionType);
+ TIFFSetField(image(), TIFFTAG_FAXMODE, m_options->faxMode);
+ TIFFSetField(image(), TIFFTAG_JPEGQUALITY, m_options->jpegQuality);
+ TIFFSetField(image(), TIFFTAG_ZIPQUALITY, m_options->deflateCompress);
+ TIFFSetField(image(), TIFFTAG_PIXARLOGQUALITY, m_options->pixarLogCompress);
+
+ // Set the predictor
+ TIFFSetField(image(), TIFFTAG_PREDICTOR, m_options->predictor);
+
+ // Use contiguous configuration
+ TIFFSetField(image(), TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
+ // Use 8 rows per strip
+ TIFFSetField(image(), TIFFTAG_ROWSPERSTRIP, 8);
+
+ // Save profile
+ KisProfile* profile = pd->colorSpace()->getProfile();
+ if(profile)
+ {
+ TQByteArray ba = profile->annotation()->annotation();
+ TIFFSetField(image(), TIFFTAG_ICCPROFILE, ba.size(),ba.data());
+ }
+ tsize_t stripsize = TIFFStripSize(image());
+ tdata_t buff = _TIFFmalloc(stripsize);
+ TQ_INT32 height = layer->image()->height();
+ TQ_INT32 width = layer->image()->width();
+ bool r = true;
+ for (int y = 0; y < height; y++) {
+ KisHLineIterator it = layer->paintDevice()->createHLineIterator(0, y, width, false);
+ switch(color_type)
+ {
+ case PHOTOMETRIC_MINISBLACK:
+ {
+ TQ_UINT8 poses[]={ 0,1 };
+ r = copyDataToStrips(it, buff, depth, 1, poses);
+ }
+ break;
+ case PHOTOMETRIC_RGB:
+ {
+ TQ_UINT8 poses[]={ 2, 1, 0, 3};
+ r = copyDataToStrips(it, buff, depth, 3, poses);
+ }
+ break;
+ case PHOTOMETRIC_SEPARATED:
+ {
+ TQ_UINT8 poses[]={ 0, 1, 2, 3, 4 };
+ r = copyDataToStrips(it, buff, depth, 4, poses);
+ }
+ break;
+ case PHOTOMETRIC_CIELAB:
+ {
+ TQ_UINT8 poses[]={ 0, 1, 2, 3 };
+ r = copyDataToStrips(it, buff, depth, 3, poses);
+ }
+ break;
+ return false;
+ }
+ if(!r) return false;
+ TIFFWriteScanline(image(), buff, y, (tsample_t) -1);
+ }
+ _TIFFfree(buff);
+ TIFFWriteDirectory(image());
+ return true;
+}
+bool KisTIFFWriterVisitor::visit(KisGroupLayer *layer)
+{
+ kdDebug(41008) << "Visiting on grouplayer " << layer->name() << "\n";
+ KisLayerSP child = layer->firstChild();
+ while (child) {
+ child->accept(*this);
+ child = child->nextSibling();
+ }
+ return true;
+}
+
+bool KisTIFFWriterVisitor::visit(KisPartLayer *)
+{
+ return true;
+}
diff --git a/filters/chalk/tiff/kis_tiff_writer_visitor.h b/filters/chalk/tiff/kis_tiff_writer_visitor.h
new file mode 100644
index 00000000..abd1aec7
--- /dev/null
+++ b/filters/chalk/tiff/kis_tiff_writer_visitor.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2006 Cyrille Berger <[email protected]>
+ *
+ * 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_TIFF_WRITER_VISITOR_H
+#define KIS_TIFF_WRITER_VISITOR_H
+
+#include <kis_layer_visitor.h>
+
+#include <kis_iterators_pixel.h>
+
+#include <tiffio.h>
+
+class KisTIFFOptions;
+
+/**
+ @author Cyrille Berger <[email protected]>
+*/
+class KisTIFFWriterVisitor : public KisLayerVisitor
+{
+ public:
+ KisTIFFWriterVisitor(TIFF*img, KisTIFFOptions* options);
+ ~KisTIFFWriterVisitor();
+ public:
+ virtual bool visit(KisPaintLayer *layer);
+ virtual bool visit(KisGroupLayer *layer);
+ virtual bool visit(KisPartLayer *layer);
+ virtual bool visit(KisAdjustmentLayer* ) { return true; }
+ private:
+ inline TIFF* image() { return m_image; }
+ inline bool saveAlpha();
+ bool copyDataToStrips( KisHLineIterator it, tdata_t buff, uint8 depth, uint8 nbcolorssamples, TQ_UINT8* poses);
+ private:
+ TIFF* m_image;
+ KisTIFFOptions* m_options;
+};
+
+#endif
diff --git a/filters/chalk/tiff/kis_tiff_ycbcr_reader.cc b/filters/chalk/tiff/kis_tiff_ycbcr_reader.cc
new file mode 100644
index 00000000..ce5e4ae9
--- /dev/null
+++ b/filters/chalk/tiff/kis_tiff_ycbcr_reader.cc
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 2006 Cyrille Berger <[email protected]>
+ *
+ * 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 "kis_tiff_ycbcr_reader.h"
+
+#include <kis_iterators_pixel.h>
+#include <kis_paint_device.h>
+
+#include "kis_tiff_stream.h"
+
+
+KisTIFFYCbCrReaderTarget8Bit::KisTIFFYCbCrReaderTarget8Bit( KisPaintDeviceSP device, TQ_UINT8* poses, int8 alphapos, uint8 sourceDepth, uint8 nbcolorssamples, uint8 extrasamplescount, cmsHTRANSFORM transformProfile, KisTIFFPostProcessor* postprocessor, uint16 hsub, uint16 vsub, KisTIFFYCbCr::Position position ) : KisTIFFReaderBase(device, poses, alphapos, sourceDepth, nbcolorssamples, extrasamplescount, transformProfile, postprocessor), m_hsub(hsub), m_vsub(vsub), m_position(position)
+{
+ // Initialize the buffer
+ TQ_INT32 imagewidth = device->image()->width();
+ if(2*(imagewidth / 2) != imagewidth) imagewidth++;
+ m_bufferWidth = imagewidth / m_hsub;
+ TQ_INT32 imageheight = device->image()->height();
+ if(2*(imageheight / 2) != imageheight) imageheight++;
+ m_bufferHeight = imageheight / m_vsub;
+ m_bufferCb = new TQ_UINT8[ m_bufferWidth * m_bufferHeight ];
+ m_bufferCr = new TQ_UINT8[ m_bufferWidth * m_bufferHeight ];
+}
+
+KisTIFFYCbCrReaderTarget8Bit::~KisTIFFYCbCrReaderTarget8Bit()
+{
+ delete[] m_bufferCb;
+ delete[] m_bufferCr;
+}
+
+uint KisTIFFYCbCrReaderTarget8Bit::copyDataToChannels( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 dataWidth, TIFFStreamBase* tiffstream)
+{
+ int numcols = dataWidth / m_hsub;
+ double coeff = TQ_UINT8_MAX / (double)( pow(2, sourceDepth() ) - 1 );
+// kdDebug(41008) << " depth expension coefficient : " << coeff << endl;
+// kdDebug(41008) << " y = " << y << endl;
+ uint buffPos = y / m_vsub * m_bufferWidth + x / m_hsub ;
+ for(int index = 0; index < numcols; index++)
+ {
+ KisHLineIterator it = paintDevice() -> createHLineIterator(x + m_hsub * index, y, m_hsub, true);
+ for( int vindex = 0; vindex < m_vsub; vindex++)
+ {
+ while( !it.isDone() )
+ {
+ TQ_UINT8 *d = it.rawData();
+ d[0] = (TQ_UINT8)( tiffstream->nextValue() * coeff );
+ d[3] = TQ_UINT8_MAX;
+ for(int k = 0; k < nbExtraSamples(); k++)
+ {
+ if(k == alphaPos())
+ d[3] = (TQ_UINT32) ( tiffstream->nextValue() * coeff );
+ else
+ tiffstream->nextValue();
+ }
+ ++it;
+ }
+ it.nextRow();
+ }
+ m_bufferCb[ buffPos ] = (TQ_UINT8)(tiffstream->nextValue() * coeff);
+ m_bufferCr[ buffPos ] = (TQ_UINT8)(tiffstream->nextValue() * coeff);
+ buffPos ++;
+ }
+ return m_vsub;
+}
+
+void KisTIFFYCbCrReaderTarget8Bit::finalize()
+{
+ KisHLineIterator it = paintDevice() -> createHLineIterator(0, 0, paintDevice()->image()->width(), true);
+ for(int y = 0; y < paintDevice()->image()->height(); y++)
+ {
+ int x = 0;
+ while(!it.isDone())
+ {
+ TQ_UINT8 *d = it.rawData();
+ int index = x/m_hsub + y/m_vsub * m_bufferWidth;
+ d[1] = m_bufferCb[ index ];
+ d[2] = m_bufferCr[ index ];
+ ++it; ++x;
+ }
+ it.nextRow();
+ }
+}
+
+KisTIFFYCbCrReaderTarget16Bit::KisTIFFYCbCrReaderTarget16Bit( KisPaintDeviceSP device, TQ_UINT8* poses, int8 alphapos, uint8 sourceDepth, uint8 nbcolorssamples, uint8 extrasamplescount, cmsHTRANSFORM transformProfile, KisTIFFPostProcessor* postprocessor, uint16 hsub, uint16 vsub, KisTIFFYCbCr::Position position ) : KisTIFFReaderBase(device, poses, alphapos, sourceDepth, nbcolorssamples, extrasamplescount, transformProfile, postprocessor), m_hsub(hsub), m_vsub(vsub), m_position(position)
+{
+ // Initialize the buffer
+ TQ_INT32 imagewidth = device->image()->width();
+ if(2*(imagewidth / 2) != imagewidth) imagewidth++;
+ m_bufferWidth = imagewidth / m_hsub;
+ TQ_INT32 imageheight = device->image()->height();
+ if(2*(imageheight / 2) != imageheight) imageheight++;
+ m_bufferHeight = imageheight / m_vsub;
+ m_bufferCb = new TQ_UINT16[ m_bufferWidth * m_bufferHeight ];
+ m_bufferCr = new TQ_UINT16[ m_bufferWidth * m_bufferHeight ];
+}
+
+KisTIFFYCbCrReaderTarget16Bit::~KisTIFFYCbCrReaderTarget16Bit()
+{
+ delete[] m_bufferCb;
+ delete[] m_bufferCr;
+}
+
+uint KisTIFFYCbCrReaderTarget16Bit::copyDataToChannels( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 dataWidth, TIFFStreamBase* tiffstream)
+{
+ int numcols = dataWidth / m_hsub;
+ double coeff = TQ_UINT16_MAX / (double)( pow(2, sourceDepth() ) - 1 );
+// kdDebug(41008) << " depth expension coefficient : " << coeff << endl;
+// kdDebug(41008) << " y = " << y << endl;
+ uint buffPos = y / m_vsub * m_bufferWidth + x / m_hsub ;
+ for(int index = 0; index < numcols; index++)
+ {
+ KisHLineIterator it = paintDevice() -> createHLineIterator(x + m_hsub * index, y, m_hsub, true);
+ for( int vindex = 0; vindex < m_vsub; vindex++)
+ {
+ while( !it.isDone() )
+ {
+ TQ_UINT16 *d = reinterpret_cast<TQ_UINT16 *>(it.rawData());
+ d[0] = (TQ_UINT16)( tiffstream->nextValue() * coeff );
+ d[3] = TQ_UINT16_MAX;
+ for(int k = 0; k < nbExtraSamples(); k++)
+ {
+ if(k == alphaPos())
+ d[3] = (TQ_UINT32) ( tiffstream->nextValue() * coeff );
+ else
+ tiffstream->nextValue();
+ }
+ ++it;
+ }
+ it.nextRow();
+ }
+ m_bufferCb[ buffPos ] = (TQ_UINT16)(tiffstream->nextValue() * coeff);
+ m_bufferCr[ buffPos ] = (TQ_UINT16)(tiffstream->nextValue() * coeff);
+ buffPos ++;
+ }
+ return m_vsub;
+}
+
+void KisTIFFYCbCrReaderTarget16Bit::finalize()
+{
+ KisHLineIterator it = paintDevice() -> createHLineIterator(0, 0, paintDevice()->image()->width(), true);
+ for(int y = 0; y < paintDevice()->image()->height(); y++)
+ {
+ int x = 0;
+ while(!it.isDone())
+ {
+ TQ_UINT16 *d = reinterpret_cast<TQ_UINT16 *>(it.rawData());
+ int index = x/m_hsub + y/m_vsub * m_bufferWidth;
+ d[1] = m_bufferCb[ index ];
+ d[2] = m_bufferCr[ index ];
+ ++it; ++x;
+ }
+ it.nextRow();
+ }
+}
diff --git a/filters/chalk/tiff/kis_tiff_ycbcr_reader.h b/filters/chalk/tiff/kis_tiff_ycbcr_reader.h
new file mode 100644
index 00000000..e81e8893
--- /dev/null
+++ b/filters/chalk/tiff/kis_tiff_ycbcr_reader.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2006 Cyrille Berger <[email protected]>
+ *
+ * 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_TIFF_YCBCR_READER_H_
+#define _KIS_TIFF_YCBCR_READER_H_
+
+#include "kis_tiff_reader.h"
+
+namespace KisTIFFYCbCr {
+ enum Position {
+ POSITION_CENTERED = 1,
+ POSITION_COSITED = 2
+ };
+}
+
+class KisTIFFYCbCrReaderTarget8Bit : public KisTIFFReaderBase {
+ public:
+ /**
+ * @param hsub horizontal subsampling of Cb and Cr
+ * @param hsub vertical subsampling of Cb and Cr
+ */
+ KisTIFFYCbCrReaderTarget8Bit( KisPaintDeviceSP device, TQ_UINT8* poses, int8 alphapos, uint8 sourceDepth, uint8 nbcolorssamples, uint8 extrasamplescount, cmsHTRANSFORM transformProfile, KisTIFFPostProcessor* postprocessor, uint16 hsub, uint16 vsub, KisTIFFYCbCr::Position position );
+ ~KisTIFFYCbCrReaderTarget8Bit();
+ virtual uint copyDataToChannels( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 dataWidth, TIFFStreamBase* tiffstream);
+ virtual void finalize();
+ private:
+ TQ_UINT8* m_bufferCb;
+ TQ_UINT8* m_bufferCr;
+ TQ_UINT32 m_bufferWidth, m_bufferHeight;
+ uint16 m_hsub;
+ uint16 m_vsub;
+ KisTIFFYCbCr::Position m_position;
+
+};
+
+class KisTIFFYCbCrReaderTarget16Bit : public KisTIFFReaderBase {
+ public:
+ /**
+ * @param hsub horizontal subsampling of Cb and Cr
+ * @param hsub vertical subsampling of Cb and Cr
+ */
+ KisTIFFYCbCrReaderTarget16Bit( KisPaintDeviceSP device, TQ_UINT8* poses, int8 alphapos, uint8 sourceDepth, uint8 nbcolorssamples, uint8 extrasamplescount, cmsHTRANSFORM transformProfile, KisTIFFPostProcessor* postprocessor, uint16 hsub, uint16 vsub, KisTIFFYCbCr::Position position );
+ ~KisTIFFYCbCrReaderTarget16Bit();
+ virtual uint copyDataToChannels( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 dataWidth, TIFFStreamBase* tiffstream);
+ virtual void finalize();
+ private:
+ TQ_UINT16* m_bufferCb;
+ TQ_UINT16* m_bufferCr;
+ TQ_UINT32 m_bufferWidth, m_bufferHeight;
+ uint16 m_hsub;
+ uint16 m_vsub;
+ KisTIFFYCbCr::Position m_position;
+
+};
+
+
+#endif
diff --git a/filters/chalk/tiff/kis_wdg_options_tiff.ui b/filters/chalk/tiff/kis_wdg_options_tiff.ui
new file mode 100644
index 00000000..3ffc1bd4
--- /dev/null
+++ b/filters/chalk/tiff/kis_wdg_options_tiff.ui
@@ -0,0 +1,741 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>KisWdgOptionsTIFF</class>
+<widget class="TQWidget">
+ <property name="name">
+ <cstring>KisWdgOptionsTIFF</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>452</width>
+ <height>267</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="caption">
+ <string>Options of Your TIFF</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="TQGroupBox">
+ <property name="name">
+ <cstring>groupBox1</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>TIFF Options</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLayoutWidget">
+ <property name="name">
+ <cstring>tqlayout10</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Compression type:</string>
+ </property>
+ </widget>
+ <widget class="KComboBox">
+ <item>
+ <property name="text">
+ <string>None</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>JPEG DCT Compression</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Deflate (ZIP)</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Lempel-Ziv &amp; Welch (LZW)</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Leadtools JPEG2000</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>CCITT Modified Huffman RLE</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>CCITT Group 3 Fax Encoding</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>CCITT Group 4 Fax Encoding</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Pixar Log</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>kComboBoxCompressionType</cstring>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="TQLayoutWidget">
+ <property name="name">
+ <cstring>tqlayout7</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel1_3</cstring>
+ </property>
+ <property name="text">
+ <string>Predictor:</string>
+ </property>
+ </widget>
+ <widget class="KComboBox">
+ <item>
+ <property name="text">
+ <string>None</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Horizontal Differencing</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Floating PointQt::Horizontal Differencing</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>kComboBoxPredictor</cstring>
+ </property>
+ <property name="currentItem">
+ <number>0</number>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Using a predictor can improve the compression (mostly for LZW and deflate)</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="TQCheckBox">
+ <property name="name">
+ <cstring>alpha</cstring>
+ </property>
+ <property name="text">
+ <string>Store alpha &amp;channel (transparency)</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Disable to get smaller files if your image has no transparancy</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;p&gt;The Portable Network Graphics (PNG) file format allows transparancy in your image to be stored by saving an alpha channel.
+You can uncheck the box if you are not using transparancy and you want to make the resulting file smaller .&lt;br&gt;Always saving the alpha channel is recommended.&lt;/p&gt;</string>
+ </property>
+ </widget>
+ <widget class="TQCheckBox">
+ <property name="name">
+ <cstring>flatten</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>3</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Flatten the &amp;image</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>This option will merge all layers. It is advisable to check this option, otherwise other applications might not be able to read your file correctly.</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="TQWidgetStack">
+ <property name="name">
+ <cstring>codecsOptionsStack</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>NoFrame</enum>
+ </property>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>0</number>
+ </attribute>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <widget class="TQFrame">
+ <property name="name">
+ <cstring>frame4</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Plain</enum>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>1</number>
+ </attribute>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <widget class="TQGroupBox">
+ <property name="name">
+ <cstring>groupBoxJPEG</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>JPEG Compression Options</string>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel1_2</cstring>
+ </property>
+ <property name="text">
+ <string>Quality:</string>
+ </property>
+ <property name="tqalignment">
+ <set>AlignTop</set>
+ </property>
+ </widget>
+ <widget class="TQLayoutWidget">
+ <property name="name">
+ <cstring>tqlayout5</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQSlider">
+ <property name="name">
+ <cstring>qualityLevel</cstring>
+ </property>
+ <property name="minValue">
+ <number>0</number>
+ </property>
+ <property name="maxValue">
+ <number>100</number>
+ </property>
+ <property name="lineStep">
+ <number>1</number>
+ </property>
+ <property name="pageStep">
+ <number>1</number>
+ </property>
+ <property name="value">
+ <number>80</number>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="tickmarks">
+ <enum>Both</enum>
+ </property>
+ <property name="tickInterval">
+ <number>10</number>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>These settings determine how much information is lost during compression</string>
+ </property>
+ </widget>
+ <widget class="TQLayoutWidget">
+ <property name="name">
+ <cstring>tqlayout4_2</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel3</cstring>
+ </property>
+ <property name="text">
+ <string>Smallest</string>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel4</cstring>
+ </property>
+ <property name="text">
+ <string>Best</string>
+ </property>
+ <property name="tqalignment">
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+ </widget>
+ </hbox>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>2</number>
+ </attribute>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <widget class="TQGroupBox">
+ <property name="name">
+ <cstring>groupBoxDeflate</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Deflate Compression Options</string>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel1_4</cstring>
+ </property>
+ <property name="text">
+ <string>Compress:</string>
+ </property>
+ <property name="tqalignment">
+ <set>AlignTop</set>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Note: the compression level does not change the quality of the result</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;p&gt;Adjust the compression time. Better compression takes longer.
+&lt;br&gt;Note: the compression level does not change the quality of the result.&lt;/p&gt;</string>
+ </property>
+ </widget>
+ <widget class="TQLayoutWidget">
+ <property name="name">
+ <cstring>tqlayout5_2</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQSlider">
+ <property name="name">
+ <cstring>compressionLevelDeflate</cstring>
+ </property>
+ <property name="minValue">
+ <number>1</number>
+ </property>
+ <property name="maxValue">
+ <number>9</number>
+ </property>
+ <property name="pageStep">
+ <number>1</number>
+ </property>
+ <property name="value">
+ <number>6</number>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="tickmarks">
+ <enum>Both</enum>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Note: the compression level doesn't change the quality of the result</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;p&gt;Adjust the compression time. Better compression takes longer.
+&lt;br&gt;Note: the compression level doesn't change the quality of the result.&lt;/p&gt;</string>
+ </property>
+ </widget>
+ <widget class="TQLayoutWidget">
+ <property name="name">
+ <cstring>tqlayout4</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel3_2</cstring>
+ </property>
+ <property name="text">
+ <string>Fast</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;p&gt;Adjust the compression time. Better compression takes longer.
+&lt;br&gt;Note: the compression level doesn't change the quality of the result.&lt;/p&gt;</string>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel4_2</cstring>
+ </property>
+ <property name="text">
+ <string>Small</string>
+ </property>
+ <property name="tqalignment">
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;p&gt;Adjust the compression time. Better compression takes longer.
+&lt;br&gt;Note: the compression level doesn't change the quality of the result.&lt;/p&gt;</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+ </widget>
+ </hbox>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>3</number>
+ </attribute>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <widget class="TQGroupBox">
+ <property name="name">
+ <cstring>groupBoxCCITGroupCCITG3</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>CCITT Group 3 fax encoding Options</string>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Fax mode:</string>
+ </property>
+ </widget>
+ <widget class="KComboBox">
+ <item>
+ <property name="text">
+ <string>Classic</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>No RTC</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>No EOL</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>kComboBoxFaxMode</cstring>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>4</number>
+ </attribute>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <widget class="TQGroupBox">
+ <property name="name">
+ <cstring>groupBoxPixarLog</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Pixar Log Compression Options</string>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel1_4_2</cstring>
+ </property>
+ <property name="text">
+ <string>Compress:</string>
+ </property>
+ <property name="tqalignment">
+ <set>AlignTop</set>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Note: the compression level does not change the quality of the result</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;p&gt;Adjust the compression time. Better compression takes longer.
+&lt;br&gt;Note: the compression level does not change the quality of the result.&lt;/p&gt;</string>
+ </property>
+ </widget>
+ <widget class="TQLayoutWidget">
+ <property name="name">
+ <cstring>tqlayout5_2_2</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQSlider">
+ <property name="name">
+ <cstring>compressionLevelPixarLog</cstring>
+ </property>
+ <property name="minValue">
+ <number>1</number>
+ </property>
+ <property name="maxValue">
+ <number>9</number>
+ </property>
+ <property name="pageStep">
+ <number>1</number>
+ </property>
+ <property name="value">
+ <number>6</number>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="tickmarks">
+ <enum>Both</enum>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Note: the compression level doesn't change the quality of the result</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;p&gt;Adjust the compression time. Better compression takes longer.
+&lt;br&gt;Note: the compression level doesn't change the quality of the result.&lt;/p&gt;</string>
+ </property>
+ </widget>
+ <widget class="TQLayoutWidget">
+ <property name="name">
+ <cstring>tqlayout4_3</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel3_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Fast</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;p&gt;Adjust the compression time. Better compression takes longer.
+&lt;br&gt;Note: the compression level doesn't change the quality of the result.&lt;/p&gt;</string>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel4_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Small</string>
+ </property>
+ <property name="tqalignment">
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;p&gt;Adjust the compression time. Better compression takes longer.
+&lt;br&gt;Note: the compression level doesn't change the quality of the result.&lt;/p&gt;</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+ </widget>
+ </hbox>
+ </widget>
+ </hbox>
+ </widget>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer3</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>
+ </vbox>
+</widget>
+<customwidgets>
+</customwidgets>
+<tabstops>
+ <tabstop>kComboBoxCompressionType</tabstop>
+ <tabstop>kComboBoxPredictor</tabstop>
+ <tabstop>alpha</tabstop>
+ <tabstop>flatten</tabstop>
+ <tabstop>qualityLevel</tabstop>
+ <tabstop>compressionLevelDeflate</tabstop>
+ <tabstop>kComboBoxFaxMode</tabstop>
+ <tabstop>compressionLevelPixarLog</tabstop>
+</tabstops>
+<tqlayoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>kcombobox.h</includehint>
+ <includehint>kcombobox.h</includehint>
+ <includehint>kcombobox.h</includehint>
+</includehints>
+</UI>
diff --git a/filters/chalk/tiff/kis_ycbcr_colorspace.h b/filters/chalk/tiff/kis_ycbcr_colorspace.h
new file mode 100644
index 00000000..05220127
--- /dev/null
+++ b/filters/chalk/tiff/kis_ycbcr_colorspace.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2006 Cyrille Berger <[email protected]>
+ *
+ * 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_YCBCR_COLORSPACE_H
+#define KIS_YCBCR_COLORSPACE_H
+namespace {
+ const TQ_INT32 MAX_CHANNEL_YCbCr = 3;
+ const TQ_INT32 MAX_CHANNEL_YCbCrA = 4;
+}
+#endif
+