Commit 3b1ab08c authored by Boudewijn Rempt's avatar Boudewijn Rempt

Revert "Remove OpenJPEG completely"

This reverts commit 37473007.
parent 32ddc9b5
......@@ -196,6 +196,10 @@ add_subdirectory( ext_vc )
add_subdirectory( ext_gsl )
add_subdirectory( ext_fftw3 )
add_subdirectory( ext_ocio )
add_subdirectory( ext_openjpeg )
if (MSVC)
add_subdirectory( ext_pthreads )
endif (MSVC)
add_subdirectory( ext_fontconfig)
add_subdirectory( ext_freetype)
add_subdirectory( ext_qt )
......
......@@ -153,7 +153,7 @@ Note: on all operating systems the entire procedure is done in a terminal window
cmake --build . --config RelWithDebInfo --target ext_vc
cmake --build . --config RelWithDebInfo --target ext_libraw
cmake --build . --config RelWithDebInfo --target ext_giflib
```
cmake --build . --config RelWithDebInfo --target ext_openjpeg
On Linux (if you want to build your own SIP and PyQt instead of the system one)
```
......
SET(PREFIX_ext_openjpeg "${EXTPREFIX}" )
ExternalProject_Add( ext_openjpeg
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL http://files.kde.org/krita/build/dependencies/openjpeg-version.2.1.tar.gz
URL_MD5 3e1c451c087f8462955426da38aa3b3d
INSTALL_DIR ${PREFIX_ext_openjpeg}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PREFIX_ext_openjpeg} -DCMAKE_BUILD_TYPE=${GLOBAL_BUILD_TYPE} ${GLOBAL_PROFILE}
UPDATE_COMMAND ""
ALWAYS 0
DEPENDS ext_png ext_tiff ext_lcms2 ext_zlib
)
# -*- cmake -*-
# - Find OpenJPEG
# Find the OpenJPEG includes and library
# This module defines
# OPENJPEG_INCLUDE_DIR, where to find openjpeg.h, etc.
# OPENJPEG_LIBRARIES, the libraries needed to use OpenJPEG.
# OPENJPEG_FOUND, If false, do not try to use OpenJPEG.
# also defined, but not for general use are
# OPENJPEG_LIBRARY, where to find the OpenJPEG library.
find_path(OPENJPEG_INCLUDE_DIR openjpeg.h
PATHS
/usr/local/include/openjpeg
/usr/local/include
/usr/include/openjpeg
/usr/include/openjpeg-1.5
/usr/include
PATH_SUFFIXES
openjpeg-1.5
openjpeg
)
set(OPENJPEG_NAMES ${OPENJPEG_NAMES} openjpeg)
find_library(OPENJPEG_LIBRARY
NAMES ${OPENJPEG_NAMES}
PATHS
/usr/lib /usr/local/lib
)
if (OPENJPEG_LIBRARY AND OPENJPEG_INCLUDE_DIR)
set(OPENJPEG_LIBRARIES ${OPENJPEG_LIBRARY})
set(OPENJPEG_FOUND "YES")
else ()
set(OPENJPEG_FOUND "NO")
endif ()
if (OPENJPEG_FOUND)
if (NOT OPENJPEG_FIND_QUIETLY)
message(STATUS "Found OpenJPEG: ${OPENJPEG_LIBRARIES}")
endif ()
else ()
if (OPENJPEG_FIND_REQUIRED)
message(FATAL_ERROR "Could not find OpenJPEG library")
endif ()
endif ()
# Deprecated declarations.
set (NATIVE_OPENJPEG_INCLUDE_PATH ${OPENJPEG_INCLUDE_DIR} )
get_filename_component (NATIVE_OPENJPEG_LIB_PATH ${OPENJPEG_LIBRARY} PATH)
mark_as_advanced(
OPENJPEG_LIBRARY
OPENJPEG_INCLUDE_DIR
)
......@@ -27,6 +27,10 @@ if(Poppler_Qt5_FOUND)
add_subdirectory(pdf)
endif()
if(OPENJPEG_FOUND)
add_subdirectory(jp2)
endif()
if(LIBRAW_FOUND)
add_subdirectory(raw)
endif()
......
include_directories(SYSTEM ${OPENJPEG_INCLUDE_DIR})
set(libkritaconverter_LIB_SRCS
jp2_converter.cc
)
set(kritajp2import_SOURCES
jp2_import.cc
${libkritaconverter_LIB_SRCS}
)
add_library(kritajp2import MODULE ${kritajp2import_SOURCES})
target_link_libraries(kritajp2import kritaui ${OPENJPEG_LIBRARIES} )
install(TARGETS kritajp2import DESTINATION ${KRITA_PLUGIN_INSTALL_DIR})
set(kritajp2export_SOURCES
jp2_export.cc
${libkritaconverter_LIB_SRCS}
)
ki18n_wrap_ui(kritajp2export_SOURCES kis_wdg_options_jp2.ui )
add_library(kritajp2export MODULE ${kritajp2export_SOURCES})
target_link_libraries(kritajp2export kritaui ${OPENJPEG_LIBRARIES} )
install(TARGETS kritajp2export DESTINATION ${KRITA_PLUGIN_INSTALL_DIR})
install( PROGRAMS krita_jp2.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})
This diff is collapsed.
/*
* Copyright (c) 2009 Cyrille Berger <cberger@cberger.net>
*
* 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.
*/
#ifndef _JP2_CONVERTER_H_
#define _JP2_CONVERTER_H_
#include <stdio.h>
#include <QObject>
#include "kis_types.h"
#include <KisImageBuilderResult.h>
class KisDocument;
struct JP2ConvertOptions {
int rate;
int numberresolution;
};
class jp2Converter : public QObject
{
Q_OBJECT
private:
enum {
J2K_CFMT = 0,
JP2_CFMT = 1,
JPT_CFMT = 2
};
public:
jp2Converter(KisDocument *doc);
virtual ~jp2Converter();
public:
KisImageBuilder_Result buildImage(const QString &filename);
KisImageBuilder_Result buildFile(const QString &filename, KisPaintLayerSP layer, const JP2ConvertOptions& options);
/**
* Retrieve the constructed image
*/
KisImageWSP getImage();
private:
KisImageBuilder_Result decode(const QString &filename);
public Q_SLOTS:
virtual void cancel();
private:
int getFileFormat(const QString &filename) const;
private:
KisImageWSP m_image;
KisDocument *m_doc;
bool m_stop;
};
#endif
/*
* Copyright (c) 2009 Cyrille Berger <cberger@cberger.net>
*
* 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 "jp2_export.h"
#include <QCheckBox>
#include <QSlider>
#include <QApplication>
#include <KoDialog.h>
#include <kpluginfactory.h>
#include <QFileInfo>
#include <KoColorSpaceConstants.h>
#include <KisFilterChain.h>
#include <KisImportExportManager.h>
#include <kis_properties_configuration.h>
#include <kis_config.h>
#include <KisDocument.h>
#include <kis_image.h>
#include <kis_group_layer.h>
#include <kis_paint_layer.h>
#include <kis_paint_device.h>
#include "jp2_converter.h"
#include "ui_kis_wdg_options_jp2.h"
class KisExternalLayer;
K_PLUGIN_FACTORY_WITH_JSON(ExportFactory, "krita_jp2_export.json", registerPlugin<jp2Export>();)
jp2Export::jp2Export(QObject *parent, const QVariantList &) : KisImportExportFilter(parent)
{
}
jp2Export::~jp2Export()
{
}
KisImportExportFilter::ConversionStatus jp2Export::convert(const QByteArray& from, const QByteArray& to)
{
dbgFile << "JP2 export! From:" << from << ", To:" << to << "";
if (from != "application/x-krita")
return KisImportExportFilter::NotImplemented;
KisDocument *input = inputDocument();
QString filename = outputFile();
if (!input)
return KisImportExportFilter::NoDocumentCreated;
KisImageWSP image = input->image();
Q_CHECK_PTR(image);
if (filename.isEmpty()) return KisImportExportFilter::FileNotFound;
KoDialog* kdb = new KoDialog(0);
kdb->setWindowTitle(i18n("JPEG 2000 Export Options"));
kdb->setButtons(KoDialog::Ok | KoDialog::Cancel);
Ui::WdgOptionsJP2 optionsJP2;
QWidget* wdg = new QWidget(kdb);
optionsJP2.setupUi(wdg);
QString filterConfig = KisConfig().exportConfiguration("JP2");
KisPropertiesConfiguration cfg;
cfg.fromXML(filterConfig);
optionsJP2.numberResolutions->setValue(cfg.getInt("number_resolutions", 6));
optionsJP2.qualityLevel->setValue(cfg.getInt("quality", 100));
kdb->setMainWidget(wdg);
QApplication::restoreOverrideCursor();
if (!getBatchMode()) {
if (kdb->exec() == QDialog::Rejected) {
return KisImportExportFilter::UserCancelled;
}
}
JP2ConvertOptions options;
options.numberresolution = optionsJP2.numberResolutions->value();
cfg.setProperty("number_resolutions", options.numberresolution);
options.rate = optionsJP2.qualityLevel->value();
cfg.setProperty("quality", options.rate);
KisConfig().setExportConfiguration("JP2", cfg);
// the image must be locked at the higher levels
KIS_SAFE_ASSERT_RECOVER_NOOP(input->image()->locked());
jp2Converter kpc(input);
KisPaintDeviceSP pd = new KisPaintDevice(*image->projection());
KisPaintLayerSP l = new KisPaintLayer(image, "projection", OPACITY_OPAQUE_U8, pd);
KisImageBuilder_Result res;
if ((res = kpc.buildFile(filename, l, options)) == KisImageBuilder_RESULT_OK) {
dbgFile << "success !";
return KisImportExportFilter::OK;
}
dbgFile << " Result =" << res;
return KisImportExportFilter::InternalError;
}
#include <jp2_export.moc>
/*
* Copyright (c) 2009 Cyrille Berger <cberger@cberger.net>
*
* 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.
*/
#ifndef _JP2_EXPORT_H_
#define _JP2_EXPORT_H_
#include <QVariant>
#include <KisImportExportFilter.h>
class jp2Export : public KisImportExportFilter
{
Q_OBJECT
public:
jp2Export(QObject *parent, const QVariantList &);
virtual ~jp2Export();
public:
virtual KisImportExportFilter::ConversionStatus convert(const QByteArray& from, const QByteArray& to);
};
#endif
/*
* Copyright (c) 2009 Cyrille Berger <cberger@cberger.net>
*
* 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 "jp2_import.h"
#include <kpluginfactory.h>
#include <QFileInfo>
#include <KisFilterChain.h>
#include <KisDocument.h>
#include <kis_image.h>
#include "jp2_converter.h"
K_PLUGIN_FACTORY_WITH_JSON(ImportFactory, "krita_jp2_import.json", registerPlugin<jp2Import>();)
jp2Import::jp2Import(QObject *parent, const QVariantList &) : KisImportExportFilter(parent)
{
}
jp2Import::~jp2Import()
{
}
KisImportExportFilter::ConversionStatus jp2Import::convert(const QByteArray&, const QByteArray& to)
{
dbgFile << "Importing using JP2Import!";
if (to != "application/x-krita")
return KisImportExportFilter::BadMimeType;
KisDocument * doc = outputDocument();
if (!doc)
return KisImportExportFilter::NoDocumentCreated;
QString filename = inputFile();
doc->prepareForImport();
if (!filename.isEmpty()) {
jp2Converter ib(doc);
switch (ib.buildImage(filename)) {
case KisImageBuilder_RESULT_UNSUPPORTED:
return KisImportExportFilter::NotImplemented;
break;
case KisImageBuilder_RESULT_INVALID_ARG:
return KisImportExportFilter::BadMimeType;
break;
case KisImageBuilder_RESULT_NO_URI:
case KisImageBuilder_RESULT_NOT_LOCAL:
return KisImportExportFilter::FileNotFound;
break;
case KisImageBuilder_RESULT_BAD_FETCH:
case KisImageBuilder_RESULT_EMPTY:
return KisImportExportFilter::ParsingError;
break;
case KisImageBuilder_RESULT_FAILURE:
return KisImportExportFilter::InternalError;
break;
case KisImageBuilder_RESULT_OK:
doc -> setCurrentImage(ib.getImage());
return KisImportExportFilter::OK;
default:
break;
}
}
return KisImportExportFilter::StorageCreationError;
}
#include <jp2_import.moc>
/*
* Copyright (c) 2009 Cyrille Berger <cberger@cberger.net>
*
* 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.
*/
#ifndef JP2_IMPORT_H_
#define JP2_IMPORT_H_
#include <QVariant>
#include <KisImportExportFilter.h>
class jp2Import : public KisImportExportFilter
{
Q_OBJECT
public:
jp2Import(QObject *parent, const QVariantList &);
virtual ~jp2Import();
public:
virtual KisImportExportFilter::ConversionStatus convert(const QByteArray& from, const QByteArray& to);
};
#endif
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>WdgOptionsJP2</class>
<widget class="QWidget" name="WdgOptionsJP2">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Compression</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="qualityLevel">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;These settings determine how much information is lost during compression. Low: small files, bad quality. High: big files, good quality.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="singleStep">
<number>10</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
<property name="tickInterval">
<number>10</number>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="intQuality">
<property name="value">
<number>100</number>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>100</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Number of resolutions:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="numberResolutions">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>20</number>
</property>
<property name="value">
<number>6</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>qualityLevel</sender>
<signal>valueChanged(int)</signal>
<receiver>intQuality</receiver>
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel">
<x>322</x>
<y>22</y>
</hint>
<hint type="destinationlabel">
<x>367</x>
<y>19</y>
</hint>
</hints>
</connection>
<connection>
<sender>intQuality</sender>
<signal>valueChanged(int)</signal>
<receiver>qualityLevel</receiver>
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel">
<x>373</x>
<y>21</y>
</hint>
<hint type="destinationlabel">
<x>328</x>
<y>18</y>
</hint>
</hints>
</connection>
</connections>
</ui>
[Desktop Entry]
Categories=Qt;KDE;Office;Graphics;
Exec=krita %u
GenericName=Application for Drawing and Handling of Images
GenericName[bg]=Приложение за рисуване и обработка на изображения