Commit 0d811d34 authored by Amyspark's avatar Amyspark
Browse files

WebP: add libwebp based file format plugin

This commit incorporates a new file format plugin based on the official
libwebp codec. It also brings new import/export dialogs that enable
access to all the available configuration parameters in libwebp as of
1.20. (I have ifdef'd the most recent bits so it should compile with the
latest LTS release.)

BUG: 414444

CCMAIL: kimageshop@kde.org
parent c24193fc
......@@ -321,3 +321,5 @@ add_subdirectory(ext_mypaint)
if (UNIX AND NOT APPLE)
add_subdirectory(ext_fcitx-qt)
endif()
add_subdirectory(ext_webp)
From 63b57144f0cfea10abbd50674bc20a2fa33cb549 Mon Sep 17 00:00:00 2001
From: "L. E. Segovia" <amy@amyspark.me>
Date: Sun, 6 Jun 2021 13:47:25 +0000
Subject: [PATCH] Fix CMake targets install directory
---
CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7c0e98e..3054fbc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -668,7 +668,7 @@ install(TARGETS ${INSTALLED_LIBRARIES}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
-set(ConfigPackageLocation ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake/)
+set(ConfigPackageLocation ${CMAKE_INSTALL_DATADIR}/cmake/${PROJECT_NAME})
install(EXPORT ${PROJECT_NAME}Targets
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${ConfigPackageLocation})
--
2.31.1
SET(EXTPREFIX_webp "${EXTPREFIX}" )
ExternalProject_Add( ext_webp
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.2.0.tar.gz
URL_HASH SHA512=c46b41899a543cc80914c89646dd607dbb5d025a9727dd83ef70994b9310eedc697666bd812141a90aa16632a9a354a031d9360a9ee1112295c7e154e69f0b74
PATCH_COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/0001-Fix-CMake-targets-install-directory.patch
# Google specifies types for most of its library components
# forcing a shared lib makes it not export a .lib on MSVC
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTPREFIX_webp} -DCMAKE_BUILD_TYPE=${GLOBAL_BUILD_TYPE} -DBUILD_SHARED_LIBS=OFF ${GLOBAL_PROFILE}
UPDATE_COMMAND ""
)
......@@ -697,6 +697,18 @@ endif()
############################
###########################
find_package(WebP 0.6.1)
set_package_properties(WebP PROPERTIES
URL "https://developers.google.com/speed/webp"
TYPE OPTIONAL
PURPOSE "Required by the WebP plugin"
)
if(WebP_FOUND)
get_target_property(WebP_LIBRARY WebP::webp "LOCATION")
list (APPEND ANDROID_EXTRA_LIBS ${WebP_LIBRARY})
endif()
##
## Test for KSeExpr
##
......
......@@ -861,7 +861,7 @@ set EXT_TARGETS=%EXT_TARGETS% ocio openexr png icoutils tiff gsl vc libraw
set EXT_TARGETS=%EXT_TARGETS% giflib qt kwindowsystem drmingw gmic freetype poppler
set EXT_TARGETS=%EXT_TARGETS% python sip pyqt
set EXT_TARGETS=%EXT_TARGETS% lzma quazip openjpeg libde265 libx265 libheif
set EXT_TARGETS=%EXT_TARGETS% seexpr mypaint
set EXT_TARGETS=%EXT_TARGETS% seexpr mypaint webp
for %%a in (%EXT_TARGETS%) do (
echo Building ext_%%a...
......
......@@ -891,7 +891,7 @@ set EXT_TARGETS=%EXT_TARGETS% ocio openexr png icoutils tiff gsl vc libraw
set EXT_TARGETS=%EXT_TARGETS% giflib qt kwindowsystem drmingw gmic freetype poppler
set EXT_TARGETS=%EXT_TARGETS% python sip pyqt
set EXT_TARGETS=%EXT_TARGETS% lzma quazip openjpeg libde265 libx265 libheif
set EXT_TARGETS=%EXT_TARGETS% seexpr mypaint
set EXT_TARGETS=%EXT_TARGETS% seexpr mypaint webp
for %%a in (%EXT_TARGETS%) do (
echo Building ext_%%a...
......
# Copyright (C) 2020 Sony Interactive Entertainment Inc.
# Copyright (C) 2012 Raphael Kubo da Costa <rakuco@webkit.org>
# Copyright (C) 2013 Igalia S.L.
# Copyright (C) 2021 L. E. Segovia <amy@amyspark.me>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS
# IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#[=======================================================================[.rst:
FindWebP
--------------
Find WebP headers and libraries.
Imported Targets
^^^^^^^^^^^^^^^^
``WebP::webp``
The WebP library, if found.
``WebP::webpdemux``
The WebP demux library, if found.
``WebP::webpmux``
The WebP mux library, if found.
``WebP::webpdecoder``
The WebP decoder library, if found.
Result Variables
^^^^^^^^^^^^^^^^
This will define the following variables in your project:
``WebP_FOUND``
true if (the requested version of) WebP is available.
``WebP_VERSION``
the version of WebP.
``WebP_LIBRARIES``
the libraries to link against to use WebP.
``WebP_INCLUDE_DIRS``
where to find the WebP headers.
``WebP_COMPILE_OPTIONS``
this should be passed to target_compile_options(), if the
target is not used for linking
#]=======================================================================]
include(FindPackageHandleStandardArgs)
set(PC_WEBP_CONFIG_DIR)
foreach(_dir ${CMAKE_PREFIX_PATH})
list(APPEND PC_WEBP_CONFIG_DIR ${_dir}/share/WebP/cmake)
endforeach()
mark_as_advanced(PC_WEBP_CONFIG_DIR)
find_package(WebP QUIET NO_MODULE
HINTS ${PC_WEBP_CONFIG_DIR} /usr/share/WebP/cmake /usr/local/share/WebP/cmake
)
mark_as_advanced(WebP_DIR)
# if we found the WebP CMake package then we are done, and
# can print what we found and return.
if(WebP_FOUND)
find_package_handle_standard_args(WebP HANDLE_COMPONENTS CONFIG_MODE)
message(STATUS "WebP found using CMake Config module.")
return()
endif()
find_package(PkgConfig QUIET)
pkg_check_modules(PC_WEBP QUIET libwebp)
set(WebP_COMPILE_OPTIONS ${PC_WEBP_CFLAGS_OTHER})
set(WebP_VERSION ${PC_WEBP_CFLAGS_VERSION})
find_path(WebP_INCLUDE_DIR
NAMES webp/decode.h
HINTS ${PC_WEBP_INCLUDEDIR} ${PC_WEBP_INCLUDE_DIRS}
)
find_library(WebP_LIBRARY
NAMES ${WebP_NAMES} webp
HINTS ${PC_WEBP_LIBDIR} ${PC_WEBP_LIBRARY_DIRS}
)
# There's nothing in the WebP headers that could be used to detect the exact
# WebP version being used so don't attempt to do so. A version can only be found
# through pkg-config
if ("${WebP_FIND_VERSION}" VERSION_GREATER "${WebP_VERSION}")
if (WebP_VERSION)
message(FATAL_ERROR "Required version (" ${WebP_FIND_VERSION} ") is higher than found version (" ${WebP_VERSION} ")")
else ()
message(WARNING "Cannot determine WebP version without pkg-config")
endif ()
endif ()
# Find components
if (WebP_INCLUDE_DIR AND WebP_LIBRARY)
set(_WebP_REQUIRED_LIBS_FOUND ON)
set(WebP_LIBS_FOUND "WebP (required): ${WebP_LIBRARY}")
else ()
set(_WebP_REQUIRED_LIBS_FOUND OFF)
set(WebP_LIBS_NOT_FOUND "WebP (required)")
endif ()
find_library(WebP_DEMUX_LIBRARY
NAMES ${WebP_DEMUX_NAMES} webpdemux
HINTS ${PC_WEBP_LIBDIR} ${PC_WEBP_LIBRARY_DIRS}
)
if (WebP_DEMUX_LIBRARY)
list(APPEND WebP_LIBS_FOUND "webpdemux: ${WebP_DEMUX_LIBRARY}")
else ()
list(APPEND WebP_LIBS_NOT_FOUND "webpdemux")
endif ()
find_library(WebP_MUX_LIBRARY
NAMES ${WebP_MUX_NAMES} webpmux
HINTS ${PC_WEBP_LIBDIR} ${PC_WEBP_LIBRARY_DIRS}
)
if (WebP_MUX_LIBRARY)
list(APPEND WebP_LIBS_FOUND "webpmux: ${WebP_MUX_LIBRARY}")
else ()
list(APPEND WebP_LIBS_NOT_FOUND "webpmux")
endif ()
find_library(WebP_DECODER_LIBRARY
NAMES ${WebP_DECODER_NAMES} webpdecoder
HINTS ${PC_WEBP_LIBDIR} ${PC_WEBP_LIBRARY_DIRS}
)
if (WebP_DECODER_LIBRARY)
list(APPEND WebP_LIBS_FOUND "webpdecoder: ${WebP_DECODER_LIBRARY}")
else ()
list(APPEND WebP_LIBS_NOT_FOUND "webpdecoder")
endif ()
if (NOT WebP_FIND_QUIETLY)
if (WebP_LIBS_FOUND)
message(STATUS "Found the following WebP libraries:")
foreach (found ${WebP_LIBS_FOUND})
message(STATUS " ${found}")
endforeach ()
endif ()
if (WebP_LIBS_NOT_FOUND)
message(STATUS "The following WebP libraries were not found:")
foreach (found ${WebP_LIBS_NOT_FOUND})
message(STATUS " ${found}")
endforeach ()
endif ()
endif ()
find_package_handle_standard_args(WebP
FOUND_VAR WebP_FOUND
REQUIRED_VARS WebP_INCLUDE_DIR WebP_LIBRARY _WebP_REQUIRED_LIBS_FOUND
VERSION_VAR WebP_VERSION
)
if (WebP_LIBRARY AND NOT TARGET WebP::webp)
add_library(WebP::webp UNKNOWN IMPORTED GLOBAL)
set_target_properties(WebP::webp PROPERTIES
IMPORTED_LOCATION "${WebP_LIBRARY}"
INTERFACE_COMPILE_OPTIONS "${WebP_COMPILE_OPTIONS}"
INTERFACE_INCLUDE_DIRECTORIES "${WebP_INCLUDE_DIR}"
)
endif ()
if (WebP_DEMUX_LIBRARY AND NOT TARGET WebP::webpdemux)
add_library(WebP::webpdemux UNKNOWN IMPORTED GLOBAL)
set_target_properties(WebP::webpdemux PROPERTIES
IMPORTED_LOCATION "${WebP_DEMUX_LIBRARY}"
INTERFACE_COMPILE_OPTIONS "${WebP_COMPILE_OPTIONS}"
INTERFACE_INCLUDE_DIRECTORIES "${WebP_INCLUDE_DIR}"
)
endif ()
if (WebP_MUX_LIBRARY AND NOT TARGET WebP::webpmux)
add_library(WebP::webpmux UNKNOWN IMPORTED GLOBAL)
set_target_properties(WebP::webpmux PROPERTIES
IMPORTED_LOCATION "${WebP_MUX_LIBRARY}"
INTERFACE_COMPILE_OPTIONS "${WebP_COMPILE_OPTIONS}"
INTERFACE_INCLUDE_DIRECTORIES "${WebP_INCLUDE_DIR}"
)
endif ()
if (WebP_DECODER_LIBRARY AND NOT TARGET WebP::webpdecoder)
add_library(WebP::webpdecoder UNKNOWN IMPORTED GLOBAL)
set_target_properties(WebP::webpdecoder PROPERTIES
IMPORTED_LOCATION "${WebP_DECODER_LIBRARY}"
INTERFACE_COMPILE_OPTIONS "${WebP_COMPILE_OPTIONS}"
INTERFACE_INCLUDE_DIRECTORIES "${WebP_INCLUDE_DIR}"
)
endif ()
mark_as_advanced(
WebP_INCLUDE_DIR
WebP_LIBRARY
WebP_DEMUX_LIBRARY
WebP_MUX_LIBRARY
WebP_DECODER_LIBRARY
)
if (WebP_FOUND)
set(WebP_LIBRARIES ${WebP_LIBRARY} ${WebP_DEMUX_LIBRARY} ${WebP_MUX_LIBRARY} ${WebP_DECODER_LIBRARY})
set(WebP_INCLUDE_DIRS ${WebP_INCLUDE_DIR})
endif ()
......@@ -99,6 +99,7 @@ build_ext() {
cmake --build . --config $BUILD_TYPE --target ext_eigen3 -- -j$PROC_COUNT
cmake --build . --config $BUILD_TYPE --target ext_seexpr -- -j$PROC_COUNT
cmake --build . --config $BUILD_TYPE --target ext_mypaint -- -j$PROC_COUNT
cmake --build . --config $BUILD_TYPE --target ext_webp -- -j$PROC_COUNT
cd $BUILD_ROOT
}
......
......@@ -122,3 +122,4 @@ cmake --build . --config RelWithDebInfo --target ext_libheif
cmake --build . --config RelWithDebInfo --target ext_seexpr
cmake --build . --config RelWithDebInfo --target ext_mypaint
cmake --build . --config RelWithDebInfo --target ext_fcitx-qt5
cmake --build . --config RelWithDebInfo --target ext_webp
......@@ -392,7 +392,7 @@ build_3rdparty () {
cmake_3rdparty ext_seexpr
cmake_3rdparty ext_mypaint
cmake_3rdparty ext_webp
## All builds done, creating a new install onlydeps install dir
......
......@@ -56,3 +56,7 @@ if (HEIF_FOUND)
endif()
add_subdirectory(krz)
if (WebP_FOUND)
add_subdirectory(webp)
endif()
......@@ -2,11 +2,11 @@
"Id": "Krita QImageIO Export Filter",
"NoDisplay": "true",
"Type": "Service",
"X-KDE-Export": "image/bmp,image/x-xpixmap,image/x-xbitmap,image/webp,image/vnd.microsoft.icon,image/x-portable-pixmap,image/x-portable-graymap,image/x-portable-bitmap",
"X-KDE-Export": "image/bmp,image/x-xpixmap,image/x-xbitmap,image/vnd.microsoft.icon,image/x-portable-pixmap,image/x-portable-graymap,image/x-portable-bitmap",
"X-KDE-Library": "kritaqimageioexport",
"X-KDE-ServiceTypes": [
"Krita/FileFilter"
],
"X-KDE-Weight": "1",
"X-KDE-Extensions" : "bmp,xpm,xbm,ico,webp,ppm"
"X-KDE-Extensions" : "bmp,xpm,xbm,ico,ppm"
}
......@@ -2,11 +2,11 @@
"Id": "Krita QImageIO Import Filter",
"NoDisplay": "true",
"Type": "Service",
"X-KDE-Import": "image/bmp,image/x-xpixmap,image/x-xbitmap,image/webp,image/vnd.microsoft.icon,image/x-portable-pixmap,image/x-portable-graymap,image/x-portable-bitmap",
"X-KDE-Import": "image/bmp,image/x-xpixmap,image/x-xbitmap,image/vnd.microsoft.icon,image/x-portable-pixmap,image/x-portable-graymap,image/x-portable-bitmap",
"X-KDE-Library": "kritaqimageioimport",
"X-KDE-ServiceTypes": [
"Krita/FileFilter"
],
"X-KDE-Weight": "1",
"X-KDE-Extensions" : "bmp,webp,xbm,ico,ppm"
"X-KDE-Extensions" : "bmp,xbm,ico,ppm"
}
if (WebP_FOUND)
set(kritawebpexport_SOURCES
dlg_webp_export.cpp
kis_webp_export.cpp
)
ki18n_wrap_ui(kritawebpexport_SOURCES dlg_webp_export.ui)
add_library(kritawebpexport MODULE ${kritawebpexport_SOURCES})
target_include_directories(kritawebpexport PRIVATE ${WebP_INCLUDE_DIRS})
target_link_libraries(kritawebpexport kritaui kritalibkra kritaimpex WebP::webp)
install(TARGETS kritawebpexport DESTINATION ${KRITA_PLUGIN_INSTALL_DIR})
set(kritawebpimport_SOURCES
dlg_webp_import.cpp
kis_webp_import.cpp
)
ki18n_wrap_ui(kritawebpimport_SOURCES dlg_webp_import.ui)
add_library(kritawebpimport MODULE ${kritawebpimport_SOURCES})
target_include_directories(kritawebpimport PRIVATE ${WebP_INCLUDE_DIRS})
target_link_libraries(kritawebpimport kritaui WebP::webp)
install(TARGETS kritawebpimport DESTINATION ${KRITA_PLUGIN_INSTALL_DIR})
install(PROGRAMS krita_webp.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})
endif()
/*
* This file is part of Krita
*
* SPDX-FileCopyrightText: 2021 L. E. Segovia <amy@amyspark.me>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <webp/encode.h>
#include <kis_properties_configuration.h>
#include "dlg_webp_export.h"
KisDlgWebPExport::KisDlgWebPExport(QWidget *parent)
: KisConfigWidget(parent)
{
setupUi(this);
#if WEBP_ENCODER_ABI_VERSION < 0x020f
qMin->setEnabled(false);
qMax->setEnabled(false);
#endif
preset->addItem(i18nc("WebP presets", "Default"), WEBP_PRESET_DEFAULT);
preset->addItem(i18nc("WebP presets", "Portrait"), WEBP_PRESET_PICTURE);
preset->addItem(i18nc("WebP presets", "Outdoor photo"), WEBP_PRESET_PHOTO);
preset->addItem(i18nc("WebP presets", "Line drawing"), WEBP_PRESET_DRAWING);
preset->addItem(i18nc("WebP presets", "Icon"), WEBP_PRESET_ICON);
preset->addItem(i18nc("WebP presets", "Text"), WEBP_PRESET_TEXT);
filterType->addItem(i18nc("WebP filters", "Simple"), 0);
filterType->addItem(i18nc("WebP filters", "Strong"), 1);
alphaCompression->addItem(i18nc("WebP alpha plane compression", "None"), 0);
alphaCompression->addItem(i18nc("WebP alpha plane compression", "Lossless"), 1);
preprocessing->addItem(i18nc("WebP preprocessing filters", "None"), 0);
preprocessing->addItem(i18nc("WebP preprocessing filters", "Segment-smooth"), 1);
preprocessing->addItem(i18nc("WebP preprocessing filters", "Pseudo-random dithering"), 2);
targetPSNR->setDisplayUnit(false);
targetPSNR->setSuffix(" dB");
connect(preset, SIGNAL(currentIndexChanged(int)), this, SLOT(changePreset(void)));
connect(lossless, SIGNAL(toggled(bool)), this, SLOT(changePreset(void)));
}
void KisDlgWebPExport::setConfiguration(const KisPropertiesConfigurationSP cfg)
{
preset->setCurrentIndex(cfg->getInt("preset", 0));
lossless->setChecked(cfg->getBool("lossless", true));
quality->setValue(cfg->getDouble("quality", 75.0));
tradeoff->setValue(cfg->getInt("method", 4));
dithering->setChecked(cfg->getBool("dithering", true));
targetSize->setValue(cfg->getInt("target_size", 0));
targetPSNR->setValue(cfg->getDouble("target_PSNR", 0.0));
segments->setValue(cfg->getInt("segments", 4));
snsStrength->setValue(cfg->getInt("sns_strength", 50));
filterStrength->setValue(cfg->getInt("filter_strength", 60));
filterSharpness->setValue(cfg->getInt("filter_sharpness", 0));
filterType->setCurrentIndex(cfg->getInt("filter_type", 1));
autofilter->setChecked(cfg->getBool("autofilter", false));
alphaCompression->setCurrentIndex(cfg->getInt("alpha_compression", 1));
alphaFiltering->setValue(cfg->getInt("alpha_filtering", 1));
alphaQuality->setValue(cfg->getInt("alpha_quality", 100));
pass->setValue(cfg->getInt("pass", 1));
showCompressed->setChecked(cfg->getBool("show_compressed", false));
preprocessing->setCurrentIndex(cfg->getInt("preprocessing", 0));
partitions->setValue(cfg->getInt("partitions", 0));
partitionLimit->setValue(cfg->getInt("partition_limit", 0));
emulateJPEGSize->setChecked(cfg->getBool("emulate_jpeg_size", false));
threadLevel->setChecked(cfg->getBool("thread_level", false));
lowMemory->setChecked(cfg->getBool("low_memory", false));
nearLossless->setValue(cfg->getInt("near_lossless", 100));
exact->setChecked(cfg->getBool("exact", 0));
useSharpYUV->setChecked(cfg->getBool("use_sharp_yuv", false));
#if WEBP_ENCODER_ABI_VERSION >= 0x020f
qMin->setValue(cfg->getInt("qmin", 0));
qMax->setValue(cfg->getInt("qmax", 100));
#endif
}
void KisDlgWebPExport::changePreset()
{
WebPConfig preset;
if (!WebPConfigPreset(&preset, static_cast<WebPPreset>(this->preset->currentData().value<int>()), static_cast<float>(this->quality->value()))) {
return;
}
if (this->lossless->isChecked() && !WebPConfigLosslessPreset(&preset, this->tradeoff->value())) {
return;
}
quality->setValue(static_cast<double>(preset.quality));
tradeoff->setValue(preset.method);
targetSize->setValue(preset.target_size);
targetPSNR->setValue(static_cast<double>(preset.target_PSNR));
segments->setValue(preset.segments);
snsStrength->setValue(preset.sns_strength);
filterStrength->setValue(preset.filter_strength);
filterSharpness->setValue(preset.filter_sharpness);
filterType->setCurrentIndex(preset.filter_type);
autofilter->setChecked(preset.autofilter == 1);
alphaCompression->setCurrentIndex(alphaCompression->findData(preset.alpha_compression));
alphaFiltering->setValue(preset.alpha_filtering);
alphaQuality->setValue(preset.alpha_quality);
pass->setValue(preset.pass);
showCompressed->setChecked(preset.show_compressed == 1);
preprocessing->setCurrentIndex(preprocessing->findData(preset.preprocessing));
partitions->setValue(preset.partitions);
partitionLimit->setValue(preset.partition_limit);
emulateJPEGSize->setChecked(preset.emulate_jpeg_size == 1);
threadLevel->setChecked(preset.thread_level > 0);
lowMemory->setChecked(preset.low_memory == 1);
nearLossless->setValue(preset.near_lossless);
exact->setChecked(preset.exact == 1);
useSharpYUV->setChecked(preset.use_sharp_yuv);
#if WEBP_ENCODER_ABI_VERSION >= 0x020f
qMin->setValue(preset.qmin);
qMax->setValue(preset.qmax);
#endif
}
KisPropertiesConfigurationSP KisDlgWebPExport::configuration() const
{
KisPropertiesConfigurationSP cfg(new KisPropertiesConfiguration());
cfg->setProperty("preset", preset->currentIndex());
cfg->setProperty("lossless", lossless->isChecked());
cfg->setProperty("quality", quality->value());
cfg->setProperty("method", tradeoff->value());
cfg->setProperty("dithering", dithering->isChecked());
cfg->setProperty("target_size", targetSize->value());
cfg->setProperty("target_PSNR", targetPSNR->value());
cfg->setProperty("segments", segments->value());
cfg->setProperty("sns_strength", snsStrength->value());
cfg->setProperty("filter_strength", filterStrength->value());
cfg->setProperty("filter_sharpness", filterSharpness->value());
cfg->setProperty("filter_type", filterType->currentData().value<int>());
cfg->setProperty("autofilter", autofilter->isChecked());
cfg->setProperty("alpha_compression", alphaCompression->currentData().value<int>());
cfg->setProperty("alpha_filtering", alphaFiltering->value());
cfg->setProperty("alpha_quality", alphaQuality->value());
cfg->setProperty("pass", pass->value());
cfg->setProperty("show_compressed", showCompressed->isChecked());
cfg->setProperty("preprocessing", preprocessing->currentData().value<int>());
cfg->setProperty("partitions", partitions->value());
cfg->setProperty("partition_limit", partitionLimit->value());
cfg->setProperty("emulate_jpeg_size", emulateJPEGSize->isChecked());
cfg->setProperty("thread_level", threadLevel->isChecked());
cfg->setProperty("low_memory", lowMemory->isChecked());
cfg->setProperty("near_lossless", nearLossless->value());
cfg->setProperty("exact", exact->isChecked());
cfg->setProperty("use_sharp_yuv", useSharpYUV->isChecked());
#if WEBP_ENCODER_ABI_VERSION >= 0x020f
cfg->setProperty("qmin", qMin->value());
cfg->setProperty("qmax", qMax->value());
#endif
return cfg;
}
/*
* This file is part of Krita
*
* SPDX-FileCopyrightText: 2021 L. E. Segovia <amy@amyspark.me>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef DLG_WEBP_EXPORT_H
#define DLG_WEBP_EXPORT_H
#include <kis_config_widget.h>
#include "ui_dlg_webp_export.h"
class KisDlgWebPExport : public KisConfigWidget, public Ui::DlgWebPExport
{
Q_OBJECT
public:
KisDlgWebPExport(QWidget *parent);
void setConfiguration(const KisPropertiesConfigurationSP cfg) override;
KisPropertiesConfigurationSP configuration() const override;
private Q_SLOTS:
void changePreset();
};
#endif // DLG_WEBP_EXPORT_H
This diff is collapsed.