diff --git a/libs/koplugin/KisMimeDatabase.cpp b/libs/koplugin/KisMimeDatabase.cpp index 20104124d7..3c4407b074 100644 --- a/libs/koplugin/KisMimeDatabase.cpp +++ b/libs/koplugin/KisMimeDatabase.cpp @@ -1,273 +1,278 @@ /* * Copyright (c) 2016 Boudewijn Rempt * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "KisMimeDatabase.h" #include #include #include #include #include QList KisMimeDatabase::s_mimeDatabase; QString KisMimeDatabase::mimeTypeForFile(const QString &file) { fillMimeData(); QFileInfo fi(file); QString suffix = fi.suffix().toLower(); Q_FOREACH(const KisMimeDatabase::KisMimeType &mimeType, s_mimeDatabase) { if (mimeType.suffixes.contains("*." + suffix)) { debugPlugin << "mimeTypeForFile(). KisMimeDatabase returned" << mimeType.mimeType << "for" << file; return mimeType.mimeType; } } QMimeDatabase db; QMimeType mime = db.mimeTypeForFile(file); if (mime.name() != "application/octet-stream") { debugPlugin << "mimeTypeForFile(). QMimeDatabase returned" << mime.name() << "for" << file; return mime.name(); } return ""; } QString KisMimeDatabase::mimeTypeForSuffix(const QString &suffix) { fillMimeData(); QMimeDatabase db; QString s = suffix.toLower(); if (!s.startsWith("*.")) { s = "*." + s; } Q_FOREACH(const KisMimeDatabase::KisMimeType &mimeType, s_mimeDatabase) { if (mimeType.suffixes.contains(s)) { debugPlugin << "mimeTypeForSuffix(). KisMimeDatabase returned" << mimeType.mimeType << "for" << s; return mimeType.mimeType; } } QMimeType mime = db.mimeTypeForFile(s); if (mime.name() != "application/octet-stream") { debugPlugin << "mimeTypeForSuffix(). QMimeDatabase returned" << mime.name() << "for" << s; return mime.name(); } return ""; } QString KisMimeDatabase::mimeTypeForData(const QByteArray ba) { QMimeDatabase db; QMimeType mtp = db.mimeTypeForData(ba); debugPlugin << "mimeTypeForData(). QMimeDatabase returned" << mtp.name(); return mtp.name(); } QString KisMimeDatabase::descriptionForMimeType(const QString &mimeType) { fillMimeData(); Q_FOREACH(const KisMimeDatabase::KisMimeType &m, s_mimeDatabase) { if (m.mimeType == mimeType) { debugPlugin << "descriptionForMimeType. KisMimeDatabase returned" << m.description << "for" << mimeType; return m.description; } } QMimeDatabase db; QMimeType mime = db.mimeTypeForName(mimeType); if (mime.name() != "application/octet-stream") { debugPlugin << "descriptionForMimeType. QMimeDatabase returned" << mime.comment() << "for" << mimeType; return mime.comment(); } return mimeType; } QStringList KisMimeDatabase::suffixesForMimeType(const QString &mimeType) { fillMimeData(); Q_FOREACH(const KisMimeDatabase::KisMimeType &m, s_mimeDatabase) { if (m.mimeType == mimeType) { debugPlugin << "suffixesForMimeType. KisMimeDatabase returned" << m.suffixes; return m.suffixes; } } QMimeDatabase db; QMimeType mime = db.mimeTypeForName(mimeType); if (mime.name() != "application/octet-stream" && !mime.suffixes().isEmpty()) { QString preferredSuffix = mime.preferredSuffix(); if (mimeType == "image/x-tga") { preferredSuffix = "tga"; } if (mimeType == "image/jpeg") { preferredSuffix = "jpg"; } QStringList suffixes = mime.suffixes(); if (preferredSuffix != suffixes.first()) { suffixes.removeAll(preferredSuffix); suffixes.prepend(preferredSuffix); } debugPlugin << "suffixesForMimeType. QMimeDatabase returned" << suffixes; return suffixes; } return QStringList(); } QString KisMimeDatabase::iconNameForMimeType(const QString &mimeType) { QMimeDatabase db; QMimeType mime = db.mimeTypeForName(mimeType); debugPlugin << "iconNameForMimeType" << mime.iconName(); return mime.iconName(); } void KisMimeDatabase::fillMimeData() { // This should come from the import/export plugins, but the json files aren't translated, // which is bad for the description field if (s_mimeDatabase.isEmpty()) { KisMimeType mimeType; mimeType.mimeType = "image/x-gimp-brush"; mimeType.description = i18nc("description of a file type", "Gimp Brush"); mimeType.suffixes = QStringList() << "*.gbr" << "*.vbr"; s_mimeDatabase << mimeType; mimeType.mimeType = "image/x-gimp-brush-animated"; mimeType.description = i18nc("description of a file type", "Gimp Image Hose Brush"); mimeType.suffixes = QStringList() << "*.gih"; s_mimeDatabase << mimeType; mimeType.mimeType = "image/x-adobe-brushlibrary"; mimeType.description = i18nc("description of a file type", "Adobe Brush Library"); mimeType.suffixes = QStringList() << "*.abr"; s_mimeDatabase << mimeType; mimeType.mimeType = "application/x-krita-paintoppreset"; mimeType.description = i18nc("description of a file type", "Krita Brush Preset"); mimeType.suffixes = QStringList() << "*.kpp"; s_mimeDatabase << mimeType; mimeType.mimeType = "application/x-krita-assistant"; mimeType.description = i18nc("description of a file type", "Krita Assistant"); mimeType.suffixes = QStringList() << "*.paintingassistant"; s_mimeDatabase << mimeType; + mimeType.mimeType = "image/x-r32"; + mimeType.description = i18nc("description of a file type", "R32 Heightmap"); + mimeType.suffixes = QStringList() << "*.r32"; + s_mimeDatabase << mimeType; + mimeType.mimeType = "image/x-r16"; mimeType.description = i18nc("description of a file type", "R16 Heightmap"); mimeType.suffixes = QStringList() << "*.r16"; s_mimeDatabase << mimeType; mimeType.mimeType = "image/x-r8"; mimeType.description = i18nc("description of a file type", "R8 Heightmap"); mimeType.suffixes = QStringList() << "*.r8"; s_mimeDatabase << mimeType; mimeType.mimeType = "application/x-spriter"; mimeType.description = i18nc("description of a file type", "Spriter SCML"); mimeType.suffixes = QStringList() << "*.scml"; s_mimeDatabase << mimeType; mimeType.mimeType = "image/x-svm"; mimeType.description = i18nc("description of a file type", "Starview Metafile"); mimeType.suffixes = QStringList() << "*.svm"; s_mimeDatabase << mimeType; mimeType.mimeType = "image/openraster"; mimeType.description = i18nc("description of a file type", "OpenRaster Image"); mimeType.suffixes = QStringList() << "*.ora"; s_mimeDatabase << mimeType; mimeType.mimeType = "application/x-photoshop-style-library"; mimeType.description = i18nc("description of a file type", "Photoshop Layer Style Library"); mimeType.suffixes = QStringList() << "*.asl"; s_mimeDatabase << mimeType; mimeType.mimeType = "application/x-gimp-color-palette"; mimeType.description = i18nc("description of a file type", "Color Palette"); mimeType.suffixes = QStringList() << "*.gpl" << "*.pal" << "*.act" << "*.aco" << "*.colors" << "*.xml" << "*.sbz"; s_mimeDatabase << mimeType; mimeType.mimeType = "application/x-opencolorio-configuration"; mimeType.description = i18nc("description of a file type", "OpenColorIO Configuration"); mimeType.suffixes = QStringList() << "*.ocio"; s_mimeDatabase << mimeType; mimeType.mimeType = "application/x-krita-recorded-macro"; mimeType.description = i18nc("description of a file type", "Krita Recorded Action"); mimeType.suffixes = QStringList() << "*.krarec"; s_mimeDatabase << mimeType; mimeType.mimeType = "application/x-gimp-gradient"; mimeType.description = i18nc("description of a file type", "GIMP Gradients"); mimeType.suffixes = QStringList() << "*.ggr"; s_mimeDatabase << mimeType; mimeType.mimeType = "application/x-gimp-pattern"; mimeType.description = i18nc("description of a file type", "GIMP Patterns"); mimeType.suffixes = QStringList() << "*.pat"; s_mimeDatabase << mimeType; mimeType.mimeType = "application/x-karbon-gradient"; mimeType.description = i18nc("description of a file type", "Karbon Gradients"); mimeType.suffixes = QStringList() << "*.kgr"; s_mimeDatabase << mimeType; mimeType.mimeType = "application/x-krita-bundle"; mimeType.description = i18nc("description of a file type", "Krita Resource Bundle"); mimeType.suffixes = QStringList() << "*.bundle"; s_mimeDatabase << mimeType; mimeType.mimeType = "application/x-krita-workspace"; mimeType.description = i18nc("description of a file type", "Krita Workspace"); mimeType.suffixes = QStringList() << "*.kws"; s_mimeDatabase << mimeType; mimeType.mimeType = "application/x-krita-taskset"; mimeType.description = i18nc("description of a file type", "Krita Taskset"); mimeType.suffixes = QStringList() << "*.kts"; s_mimeDatabase << mimeType; mimeType.mimeType = "image/x-krita-raw"; mimeType.description = i18nc("description of a file type", "Camera Raw Files"); mimeType.suffixes = QStringList() << "*.nef" << "*.cr2" << "*.sr2" << "*.crw" << "*.pef" << "*.x3f" << "*.kdc" << "*.mrw" << "*.arw" << "*.k25" << "*.dcr" << "*.orf" << "*.raw" << "*.raw" << "*.raf" << "*.srf" << "*.dng"; s_mimeDatabase << mimeType; mimeType.mimeType = "application/x-extension-exr"; mimeType.description = i18nc("description of a file type", "OpenEXR (Extended)"); mimeType.suffixes = QStringList() << "*.exr"; s_mimeDatabase << mimeType; mimeType.mimeType = "image/x-psb"; mimeType.description = i18nc("description of a file type", "Photoshop Image (Large)"); mimeType.suffixes = QStringList() << "*.psb"; s_mimeDatabase << mimeType; debugPlugin << "Filled mimedatabase with" << s_mimeDatabase.count() << "special mimetypes"; } } diff --git a/plugins/impex/heightmap/CMakeLists.txt b/plugins/impex/heightmap/CMakeLists.txt index f7e2a5693f..a8b03308d9 100644 --- a/plugins/impex/heightmap/CMakeLists.txt +++ b/plugins/impex/heightmap/CMakeLists.txt @@ -1,30 +1,32 @@ add_subdirectory(tests) include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ) set(kritaheightmapimport_SOURCES kis_heightmap_import.cpp kis_wdg_options_heightmap.cpp + kis_heightmap_utils.cpp ) ki18n_wrap_ui(kritaheightmapimport_SOURCES kis_wdg_options_heightmap.ui ) add_library(kritaheightmapimport MODULE ${kritaheightmapimport_SOURCES}) target_link_libraries(kritaheightmapimport kritaui ) install(TARGETS kritaheightmapimport DESTINATION ${KRITA_PLUGIN_INSTALL_DIR}) set(kritaheightmapexport_SOURCES kis_heightmap_export.cpp kis_wdg_options_heightmap.cpp + kis_heightmap_utils.cpp ) ki18n_wrap_ui(kritaheightmapexport_SOURCES kis_wdg_options_heightmap.ui ) add_library(kritaheightmapexport MODULE ${kritaheightmapexport_SOURCES}) target_link_libraries(kritaheightmapexport kritaui kritaimpex) install(TARGETS kritaheightmapexport DESTINATION ${KRITA_PLUGIN_INSTALL_DIR}) install( PROGRAMS krita_heightmap.desktop DESTINATION ${XDG_APPS_INSTALL_DIR}) diff --git a/plugins/impex/heightmap/kis_heightmap_export.cpp b/plugins/impex/heightmap/kis_heightmap_export.cpp index cf12244116..90af136a80 100644 --- a/plugins/impex/heightmap/kis_heightmap_export.cpp +++ b/plugins/impex/heightmap/kis_heightmap_export.cpp @@ -1,135 +1,149 @@ /* * Copyright (c) 2014 Boudewijn Rempt * Copyright (c) 2017 Victor Wåhlström * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; version 2.1 of the License. * * This library 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser 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_heightmap_export.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "kis_wdg_options_heightmap.h" +#include "kis_heightmap_utils.h" K_PLUGIN_FACTORY_WITH_JSON(KisHeightMapExportFactory, "krita_heightmap_export.json", registerPlugin();) template static void writeData(KisPaintDeviceSP pd, const QRect &bounds, QDataStream &out_stream) { KIS_ASSERT_RECOVER_RETURN(pd); KisSequentialConstIterator it(pd, bounds); do { out_stream << KoGrayTraits::gray(const_cast(it.rawDataConst())); } while(it.nextPixel()); } KisHeightMapExport::KisHeightMapExport(QObject *parent, const QVariantList &) : KisImportExportFilter(parent) { } KisHeightMapExport::~KisHeightMapExport() { } KisPropertiesConfigurationSP KisHeightMapExport::defaultConfiguration(const QByteArray &from, const QByteArray &to) const { Q_UNUSED(from); Q_UNUSED(to); KisPropertiesConfigurationSP cfg = new KisPropertiesConfiguration(); cfg->setProperty("endianness", 0); return cfg; } KisConfigWidget *KisHeightMapExport::createConfigurationWidget(QWidget *parent, const QByteArray &from, const QByteArray &to) const { Q_UNUSED(from); Q_UNUSED(to); bool export_mode = true; KisWdgOptionsHeightmap* wdg = new KisWdgOptionsHeightmap(parent, export_mode); return wdg; } void KisHeightMapExport::initializeCapabilities() { if (mimeType() == "image/x-r8") { QList > supportedColorModels; supportedColorModels << QPair() << QPair(GrayAColorModelID, Integer8BitsColorDepthID); addSupportedColorModels(supportedColorModels, "R8 Heightmap"); } else if (mimeType() == "image/x-r16") { QList > supportedColorModels; supportedColorModels << QPair() << QPair(GrayAColorModelID, Integer16BitsColorDepthID); addSupportedColorModels(supportedColorModels, "R16 Heightmap"); } + else if (mimeType() == "image/x-r32") { + QList > supportedColorModels; + supportedColorModels << QPair() + << QPair(GrayAColorModelID, Float32BitsColorDepthID); + addSupportedColorModels(supportedColorModels, "R32 Heightmap"); + } } KisImportExportFilter::ConversionStatus KisHeightMapExport::convert(KisDocument *document, QIODevice *io, KisPropertiesConfigurationSP configuration) { - KIS_ASSERT_RECOVER_RETURN_VALUE(mimeType() == "image/x-r16" || mimeType() == "image/x-r8", KisImportExportFilter::WrongFormat); + KIS_ASSERT_RECOVER_RETURN_VALUE(mimeType() == "image/x-r16" || mimeType() == "image/x-r8" || mimeType() == "image/x-r32", KisImportExportFilter::WrongFormat); KisImageSP image = document->savingImage(); QDataStream::ByteOrder bo = configuration->getInt("endianness", 1) == 0 ? QDataStream::BigEndian : QDataStream::LittleEndian; KisPaintDeviceSP pd = new KisPaintDevice(*image->projection()); - bool r16 = mimeType() == "image/x-r16"; - QDataStream s(io); s.setByteOrder(bo); + // needed for 32bit float data + s.setFloatingPointPrecision(QDataStream::SinglePrecision); - KoID target_comodel = GrayAColorModelID; - KoID target_codepth = r16 ? Integer16BitsColorDepthID : Integer8BitsColorDepthID; + KoID target_co_model = GrayAColorModelID; + KoID target_co_depth = KisHeightmapUtils::mimeTypeToKoID(mimeType()); + KIS_ASSERT(!target_co_depth.id().isNull()); - if (pd->colorSpace()->colorModelId() != target_comodel || pd->colorSpace()->colorDepthId() != target_codepth) { + if (pd->colorSpace()->colorModelId() != target_co_model || pd->colorSpace()->colorDepthId() != target_co_depth) { pd = new KisPaintDevice(*pd.data()); - KUndo2Command *cmd = pd->convertTo(KoColorSpaceRegistry::instance()->colorSpace(target_comodel.id(), target_codepth.id())); + KUndo2Command *cmd = pd->convertTo(KoColorSpaceRegistry::instance()->colorSpace(target_co_model.id(), target_co_depth.id())); delete cmd; } - if (r16) { + if (target_co_depth == Float32BitsColorDepthID) { + writeData(pd, image->bounds(), s); + } + else if (target_co_depth == Integer16BitsColorDepthID) { writeData(pd, image->bounds(), s); } - else { + else if (target_co_depth == Integer8BitsColorDepthID) { writeData(pd, image->bounds(), s); } + else { + return KisImportExportFilter::InternalError; + } return KisImportExportFilter::OK; } #include "kis_heightmap_export.moc" diff --git a/plugins/impex/heightmap/kis_heightmap_import.cpp b/plugins/impex/heightmap/kis_heightmap_import.cpp index 181ae83eb4..9faa5ebfaf 100644 --- a/plugins/impex/heightmap/kis_heightmap_import.cpp +++ b/plugins/impex/heightmap/kis_heightmap_import.cpp @@ -1,175 +1,184 @@ /* * Copyright (c) 2014 Boudewijn Rempt * Copyright (c) 2017 Victor Wåhlström * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser 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_heightmap_import.h" #include #include -#include #include -#include -#include -#include #include -#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "kis_wdg_options_heightmap.h" +#include "kis_heightmap_utils.h" K_PLUGIN_FACTORY_WITH_JSON(HeightMapImportFactory, "krita_heightmap_import.json", registerPlugin();) template void fillData(KisPaintDeviceSP pd, int w, int h, QDataStream &stream) { KIS_ASSERT_RECOVER_RETURN(pd); T pixel; for (int i = 0; i < h; ++i) { KisHLineIteratorSP it = pd->createHLineIteratorNG(0, i, w); do { stream >> pixel; KoGrayTraits::setGray(it->rawData(), pixel); KoGrayTraits::setOpacity(it->rawData(), OPACITY_OPAQUE_F, 1); } while(it->nextPixel()); } } KisHeightMapImport::KisHeightMapImport(QObject *parent, const QVariantList &) : KisImportExportFilter(parent) { } KisHeightMapImport::~KisHeightMapImport() { } KisImportExportFilter::ConversionStatus KisHeightMapImport::convert(KisDocument *document, QIODevice *io, KisPropertiesConfigurationSP configuration) { Q_UNUSED(configuration); - KoID depthId; - if (mimeType() == "image/x-r8") { - depthId = Integer8BitsColorDepthID; - } - else if (mimeType() == "image/x-r16") { - depthId = Integer16BitsColorDepthID; - } - else { - document->setErrorMessage(i18n("The file is not 8 or 16 bits raw")); + KoID depthId = KisHeightmapUtils::mimeTypeToKoID(mimeType()); + if (depthId.id().isNull()) { + document->setErrorMessage(i18n("Unknown file type")); return KisImportExportFilter::WrongFormat; } QApplication::restoreOverrideCursor(); KoDialog* kdb = new KoDialog(0); - kdb->setWindowTitle(i18n("R16 HeightMap Import Options")); + kdb->setWindowTitle(i18n("Heightmap Import Options")); kdb->setButtons(KoDialog::Ok | KoDialog::Cancel); KisWdgOptionsHeightmap* wdg = new KisWdgOptionsHeightmap(kdb); kdb->setMainWidget(wdg); connect(wdg, SIGNAL(statusUpdated(bool)), kdb, SLOT(enableButtonOk(bool))); KisConfig config; QString filterConfig = config.importConfiguration(mimeType()); KisPropertiesConfigurationSP cfg(new KisPropertiesConfiguration); cfg->fromXML(filterConfig); int w = 0; int h = 0; int endianness = cfg->getInt("endianness", 1); if (endianness == 0) { wdg->radioBig->setChecked(true); } else { wdg->radioLittle->setChecked(true); } KIS_ASSERT(io->isOpen()); quint64 size = io->size(); wdg->fileSizeLabel->setText(QString::number(size)); - int bpp = mimeType() == "image/x-r16" ? 16 : 8; - - wdg->bppLabel->setText(QString::number(bpp)); + if(depthId == Integer8BitsColorDepthID) { + wdg->bppLabel->setText(QString::number(8)); + wdg->typeLabel->setText("Integer"); + } + else if(depthId == Integer16BitsColorDepthID) { + wdg->bppLabel->setText(QString::number(16)); + wdg->typeLabel->setText("Integer"); + } + else if(depthId == Float32BitsColorDepthID) { + wdg->bppLabel->setText(QString::number(32)); + wdg->typeLabel->setText("Float"); + } + else { + return KisImportExportFilter::InternalError; + } if (!batchMode()) { if (kdb->exec() == QDialog::Rejected) { return KisImportExportFilter::UserCancelled; } } cfg->setProperty("endianness", wdg->radioBig->isChecked() ? 0 : 1); config.setImportConfiguration(mimeType(), cfg); w = wdg->widthInput->value(); h = wdg->heightInput->value(); QDataStream::ByteOrder bo = QDataStream::LittleEndian; cfg->setProperty("endianness", 1); if (wdg->radioBig->isChecked()) { bo = QDataStream::BigEndian; cfg->setProperty("endianness", 0); } KisConfig().setExportConfiguration(mimeType(), cfg); QDataStream s(io); s.setByteOrder(bo); + // needed for 32bit float data + s.setFloatingPointPrecision(QDataStream::SinglePrecision); const KoColorSpace *colorSpace = KoColorSpaceRegistry::instance()->colorSpace(GrayAColorModelID.id(), depthId.id(), 0); KisImageSP image = new KisImage(document->createUndoStore(), w, h, colorSpace, "imported heightmap"); KisPaintLayerSP layer = new KisPaintLayer(image, image->nextLayerName(), 255); - bool r16 = (depthId == Integer16BitsColorDepthID); - if (r16) { + if (depthId == Float32BitsColorDepthID) { + fillData(layer->paintDevice(), w, h, s); + } + else if (depthId == Integer16BitsColorDepthID) { fillData(layer->paintDevice(), w, h, s); } - else { + else if (depthId == Integer8BitsColorDepthID) { fillData(layer->paintDevice(), w, h, s); } + else { + return KisImportExportFilter::InternalError; + } image->addNode(layer.data(), image->rootLayer().data()); document->setCurrentImage(image); return KisImportExportFilter::OK; } #include "kis_heightmap_import.moc" diff --git a/plugins/impex/heightmap/kis_heightmap_utils.cpp b/plugins/impex/heightmap/kis_heightmap_utils.cpp new file mode 100644 index 0000000000..d1005a873f --- /dev/null +++ b/plugins/impex/heightmap/kis_heightmap_utils.cpp @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2017 Victor Wåhlström + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser 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_heightmap_utils.h" + +#include +#include + +KoID KisHeightmapUtils::mimeTypeToKoID(const QByteArray& mimeType) +{ + if (mimeType == "image/x-r8") { + return Integer8BitsColorDepthID; + } + else if (mimeType == "image/x-r16") { + return Integer16BitsColorDepthID; + } + else if (mimeType == "image/x-r32") { + return Float32BitsColorDepthID; + } + return KoID(); +} diff --git a/plugins/impex/heightmap/kis_heightmap_utils.h b/plugins/impex/heightmap/kis_heightmap_utils.h new file mode 100644 index 0000000000..d5ecb0f3a4 --- /dev/null +++ b/plugins/impex/heightmap/kis_heightmap_utils.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2017 Victor Wåhlström + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser 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_HEIGHTMAP_UTILS_H_ +#define _KIS_HEIGHTMAP_UTILS_H_ + +#include + +namespace KisHeightmapUtils +{ +KoID mimeTypeToKoID(const class QByteArray& mimeType); +} + +#endif // _KIS_HEIGHTMAP_UTILS_H_ diff --git a/plugins/impex/heightmap/kis_wdg_options_heightmap.ui b/plugins/impex/heightmap/kis_wdg_options_heightmap.ui index e979c2d2ca..f6bf64afd0 100644 --- a/plugins/impex/heightmap/kis_wdg_options_heightmap.ui +++ b/plugins/impex/heightmap/kis_wdg_options_heightmap.ui @@ -1,206 +1,220 @@ WdgOptionsHeightMap 0 0 355 - 289 + 319 0 0 0 0 File size: 0 0 File size (bytes) 0 - + Endianness: - + Little Endian &Little true endiannessButtonGroup Big Endian &Big endiannessButtonGroup - + Guess width and height based on file size and bits per pixel. Only values set to 0 will be updated. Guess dimensions Height: px 0 0 Height of image in pixels. 999999999 px 0 0 Width of image in pixels. 999999999 Width: - + Bits per pixel: 0 + + + + Type: + + + + + + + + + + radioLittle radioBig widthInput heightInput guessButton diff --git a/plugins/impex/heightmap/krita_heightmap_export.json b/plugins/impex/heightmap/krita_heightmap_export.json index fe1b861c89..0f100aa61e 100644 --- a/plugins/impex/heightmap/krita_heightmap_export.json +++ b/plugins/impex/heightmap/krita_heightmap_export.json @@ -1,14 +1,14 @@ { "Icon": "", - "Id": "Krita HeightMap Export Filter", + "Id": "Krita Heightmap Export Filter", "NoDisplay": "true", "Type": "Service", - "X-KDE-Export": "image/x-r16,image/x-r8", - + + "X-KDE-Export": "image/x-r32,image/x-r16,image/x-r8", "X-KDE-Library": "kritaheightmapexport", "X-KDE-ServiceTypes": [ "Krita/FileFilter" ], "X-KDE-Weight": "1", - "X-KDE-Extensions" : "r16,r8" + "X-KDE-Extensions" : "r32,r16,r8" } diff --git a/plugins/impex/heightmap/krita_heightmap_import.json b/plugins/impex/heightmap/krita_heightmap_import.json index 03ae647d17..8c1ea9a41e 100644 --- a/plugins/impex/heightmap/krita_heightmap_import.json +++ b/plugins/impex/heightmap/krita_heightmap_import.json @@ -1,14 +1,14 @@ { "Icon": "", - "Id": "Krita HeightMap Import Filter", + "Id": "Krita Heightmap Import Filter", "NoDisplay": "true", "Type": "Service", - "X-KDE-Import": "image/x-r16,image/x-r8", + "X-KDE-Import": "image/x-r32,image/x-r16,image/x-r8", "X-KDE-Library": "kritaheightmapimport", "X-KDE-ServiceTypes": [ "Krita/FileFilter" ], "X-KDE-Weight": "1", - "X-KDE-Extensions" : "r16,r8" + "X-KDE-Extensions" : "r32,r16,r8" }