JXR support
CCBUG: 451584 An implementation of the JXR format.
@ -75,13 +75,18 @@ if(KIMAGEFORMATS_JXL)
|
|||||||
endif()
|
endif()
|
||||||
add_feature_info(LibJXL LibJXL_FOUND "required for the QImage plugin for JPEG XL images")
|
add_feature_info(LibJXL LibJXL_FOUND "required for the QImage plugin for JPEG XL images")
|
||||||
|
|
||||||
# note: module FindLibRaw missing from https://invent.kde.org/frameworks/extra-cmake-modules
|
|
||||||
find_package(LibRaw 0.20.2)
|
find_package(LibRaw 0.20.2)
|
||||||
set_package_properties(LibRaw PROPERTIES
|
set_package_properties(LibRaw PROPERTIES
|
||||||
TYPE OPTIONAL
|
TYPE OPTIONAL
|
||||||
PURPOSE "Required for the QImage plugin for RAW images"
|
PURPOSE "Required for the QImage plugin for RAW images"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
option(KIMAGEFORMATS_JXR "Enable plugin for JPEG XR format" ON)
|
||||||
|
if(KIMAGEFORMATS_JXR)
|
||||||
|
find_package(LibJXR)
|
||||||
|
endif()
|
||||||
|
add_feature_info(LibJXR LibJXR_FOUND "required for the QImage plugin for JPEG XR images")
|
||||||
|
|
||||||
ecm_set_disabled_deprecation_versions(
|
ecm_set_disabled_deprecation_versions(
|
||||||
QT 6.5
|
QT 6.5
|
||||||
KF 5.102
|
KF 5.102
|
||||||
|
@ -28,6 +28,7 @@ The following image formats have read and write support:
|
|||||||
- Encapsulated PostScript (eps)
|
- Encapsulated PostScript (eps)
|
||||||
- High Efficiency Image File Format (heif). Can be enabled with the KIMAGEFORMATS_HEIF build option.
|
- High Efficiency Image File Format (heif). Can be enabled with the KIMAGEFORMATS_HEIF build option.
|
||||||
- JPEG XL (jxl)
|
- JPEG XL (jxl)
|
||||||
|
- JPEG XR (jxr)
|
||||||
- OpenEXR (exr)
|
- OpenEXR (exr)
|
||||||
- Personal Computer Exchange (pcx)
|
- Personal Computer Exchange (pcx)
|
||||||
- Quite OK Image format (qoi)
|
- Quite OK Image format (qoi)
|
||||||
|
@ -114,6 +114,15 @@ if (LibJXL_FOUND AND LibJXLThreads_FOUND)
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (LibJXR_FOUND)
|
||||||
|
kimageformats_read_tests(
|
||||||
|
jxr
|
||||||
|
)
|
||||||
|
kimageformats_write_tests(
|
||||||
|
jxr-nodatacheck
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Allow some fuzziness when reading this formats, to allow for
|
# Allow some fuzziness when reading this formats, to allow for
|
||||||
# rounding errors (eg: in alpha blending).
|
# rounding errors (eg: in alpha blending).
|
||||||
kimageformats_read_tests(FUZZ 1
|
kimageformats_read_tests(FUZZ 1
|
||||||
|
BIN
autotests/read/jxr/abydos_bgra32.jxr
Normal file
BIN
autotests/read/jxr/abydos_bgra32.png
Normal file
After Width: | Height: | Size: 206 KiB |
BIN
autotests/read/jxr/testcard_bgra8.jxr
Normal file
BIN
autotests/read/jxr/testcard_bgra8.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
autotests/read/jxr/testcard_gray16.jxr
Normal file
BIN
autotests/read/jxr/testcard_gray16.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
autotests/read/jxr/testcard_gray8.jxr
Normal file
BIN
autotests/read/jxr/testcard_gray8.png
Normal file
After Width: | Height: | Size: 6.8 KiB |
BIN
autotests/read/jxr/testcard_mono.jxr
Normal file
BIN
autotests/read/jxr/testcard_mono.png
Normal file
After Width: | Height: | Size: 8.2 KiB |
BIN
autotests/read/jxr/testcard_rgb16.jxr
Normal file
BIN
autotests/read/jxr/testcard_rgb16.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
autotests/read/jxr/testcard_rgb8.jxr
Normal file
BIN
autotests/read/jxr/testcard_rgb8.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
autotests/read/jxr/testcard_rgba16.jxr
Normal file
BIN
autotests/read/jxr/testcard_rgba16.png
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
autotests/read/jxr/testcard_rgba8.jxr
Normal file
BIN
autotests/read/jxr/testcard_rgba8.png
Normal file
After Width: | Height: | Size: 18 KiB |
24
cmake/find-modules/FindLibJXR.cmake
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# - Find LibJXR
|
||||||
|
# Find the JXR library
|
||||||
|
# This module defines
|
||||||
|
# LIBJXR_INCLUDE_DIRS, where to find jxrlib/JXRGlue.h
|
||||||
|
# LIBJXR_LIBRARIES, the libraries needed to use JXR
|
||||||
|
#
|
||||||
|
# Based on cmake code found at https://github.com/microsoft/vcpkg/blob/master/ports/jxrlib/FindJXR.cmake
|
||||||
|
|
||||||
|
find_path(LIBJXR_INCLUDE_DIRS
|
||||||
|
NAMES JXRGlue.h
|
||||||
|
PATH_SUFFIXES jxrlib
|
||||||
|
)
|
||||||
|
mark_as_advanced(LIBJXR_INCLUDE_DIRS)
|
||||||
|
|
||||||
|
include(SelectLibraryConfigurations)
|
||||||
|
|
||||||
|
find_library(LIBJPEGXR_LIBRARY NAMES jpegxr)
|
||||||
|
find_library(LIBJXRGLUE_LIBRARY NAMES jxrglue)
|
||||||
|
|
||||||
|
set(LIBJXR_LIBRARIES ${LIBJPEGXR_LIBRARY} ${LIBJXRGLUE_LIBRARY})
|
||||||
|
mark_as_advanced(LIBJXR_LIBRARIES)
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibJXR DEFAULT_MSG LIBJXR_INCLUDE_DIRS LIBJXR_LIBRARIES)
|
@ -115,6 +115,20 @@ endif()
|
|||||||
|
|
||||||
##################################
|
##################################
|
||||||
|
|
||||||
|
if (LibJXR_FOUND)
|
||||||
|
kimageformats_add_plugin(kimg_jxr SOURCES jxr.cpp)
|
||||||
|
kde_enable_exceptions()
|
||||||
|
target_include_directories(kimg_jxr PRIVATE ${LIBJXR_INCLUDE_DIRS})
|
||||||
|
target_link_libraries(kimg_jxr PRIVATE jpegxr jxrglue)
|
||||||
|
target_compile_definitions(kimg_jxr PRIVATE INITGUID)
|
||||||
|
if (NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=undef")
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=undef")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
##################################
|
||||||
|
|
||||||
if (KF6Archive_FOUND)
|
if (KF6Archive_FOUND)
|
||||||
|
|
||||||
kimageformats_add_plugin(kimg_kra SOURCES kra.cpp)
|
kimageformats_add_plugin(kimg_kra SOURCES kra.cpp)
|
||||||
|
1141
src/imageformats/jxr.cpp
Normal file
4
src/imageformats/jxr.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"Keys": [ "jxr", "wdp", "hdp" ],
|
||||||
|
"MimeTypes": [ "image/jxr", "image/vnd.ms-photo", "image/vnd.ms-photo" ]
|
||||||
|
}
|
47
src/imageformats/jxr_p.h
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the KDE project
|
||||||
|
SPDX-FileCopyrightText: 2024 Mirco Miranda <mircomir@outlook.com>
|
||||||
|
|
||||||
|
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef KIMG_JXR_P_H
|
||||||
|
#define KIMG_JXR_P_H
|
||||||
|
|
||||||
|
#include <QImageIOPlugin>
|
||||||
|
#include <QSharedDataPointer>
|
||||||
|
|
||||||
|
class JXRHandlerPrivate;
|
||||||
|
|
||||||
|
class JXRHandler : public QImageIOHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
JXRHandler();
|
||||||
|
|
||||||
|
bool canRead() const override;
|
||||||
|
bool read(QImage *outImage) override;
|
||||||
|
bool write(const QImage &image) override;
|
||||||
|
|
||||||
|
void setOption(ImageOption option, const QVariant &value) override;
|
||||||
|
bool supportsOption(QImageIOHandler::ImageOption option) const override;
|
||||||
|
QVariant option(QImageIOHandler::ImageOption option) const override;
|
||||||
|
|
||||||
|
static bool canRead(QIODevice *device);
|
||||||
|
|
||||||
|
private:
|
||||||
|
mutable QSharedDataPointer<JXRHandlerPrivate> d;
|
||||||
|
|
||||||
|
qint32 m_quality;
|
||||||
|
};
|
||||||
|
|
||||||
|
class JXRPlugin : public QImageIOPlugin
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface" FILE "jxr.json")
|
||||||
|
|
||||||
|
public:
|
||||||
|
Capabilities capabilities(QIODevice *device, const QByteArray &format) const override;
|
||||||
|
QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const override;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // KIMG_JXR_P_H
|
@ -13,6 +13,19 @@
|
|||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QImageIOHandler>
|
#include <QImageIOHandler>
|
||||||
|
|
||||||
|
// Image metadata keys to use in plugins (so they are consistent)
|
||||||
|
#define META_KEY_DESCRIPTION "Description"
|
||||||
|
#define META_KEY_MANUFACTURER "Manufacturer"
|
||||||
|
#define META_KEY_SOFTWARE "Software"
|
||||||
|
#define META_KEY_MODEL "Model"
|
||||||
|
#define META_KEY_AUTHOR "Author"
|
||||||
|
#define META_KEY_COPYRIGHT "Copyright"
|
||||||
|
#define META_KEY_CREATIONDATE "CreationDate"
|
||||||
|
#define META_KEY_TITLE "Title"
|
||||||
|
#define META_KEY_DOCUMENTNAME "DocumentName"
|
||||||
|
#define META_KEY_HOSTCOMPUTER "HostComputer"
|
||||||
|
#define META_KEY_XMP "XML:com.adobe.xmp"
|
||||||
|
|
||||||
// QList uses some extra space for stuff, hence the 32 here suggested by Thiago Macieira
|
// QList uses some extra space for stuff, hence the 32 here suggested by Thiago Macieira
|
||||||
static constexpr int kMaxQVectorSize = std::numeric_limits<int>::max() - 32;
|
static constexpr int kMaxQVectorSize = std::numeric_limits<int>::max() - 32;
|
||||||
|
|
||||||
|