From kde-commits Tue Feb 25 12:17:03 2014 From: Alex Merry Date: Tue, 25 Feb 2014 12:17:03 +0000 To: kde-commits Subject: [kimageformats] /: Remove the WebP format Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=139333063413898 Git commit 6375160828190a3fadb29fdd2765e4a74da1756b by Alex Merry. Committed on 24/02/2014 at 17:07. Pushed by alexmerry into branch 'master'. Remove the WebP format This will be in Qt 5.3. REVIEW: 116026 M +0 -6 CMakeLists.txt M +0 -3 autotests/CMakeLists.txt D +- -- autotests/read/webp/bw-cwebp-lossless.png D +- -- autotests/read/webp/bw-cwebp-lossless.webp D +- -- autotests/read/webp/bw-cwebp.png D +- -- autotests/read/webp/bw-cwebp.webp D +- -- autotests/read/webp/rgb-cwebp-lossless.png D +- -- autotests/read/webp/rgb-cwebp-lossless.webp D +- -- autotests/read/webp/rgb-cwebp.png D +- -- autotests/read/webp/rgb-cwebp.webp D +0 -203 cmake/FindWebP.cmake M +0 -22 src/imageformats/CMakeLists.txt D +0 -223 src/imageformats/webp.cpp D +0 -7 src/imageformats/webp.desktop D +0 -57 src/imageformats/webp.h D +0 -4 src/imageformats/webp.json D +0 -13 src/imageformats/webp.xml http://commits.kde.org/kimageformats/6375160828190a3fadb29fdd2765e4a74da175= 6b diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b8495d..0a47945 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,12 +44,6 @@ set_package_properties(OpenEXR PROPERTIES PURPOSE "Required for the QImage plugin for OpenEXR images" ) = -find_package(WebP COMPONENTS WebP) -set_package_properties(WebP PROPERTIES - TYPE OPTIONAL - PURPOSE "Required for the QImage plugin for WebP images" -) - add_subdirectory(src) if (BUILD_TESTING) add_subdirectory(autotests) diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt index 3e30e60..5c65084 100644 --- a/autotests/CMakeLists.txt +++ b/autotests/CMakeLists.txt @@ -82,6 +82,3 @@ endif() if (OpenEXR_FOUND) # FIXME: OpenEXR tests endif() -if (WebP_FOUND) - kimageformats_read_tests(webp) -endif() diff --git a/autotests/read/webp/bw-cwebp-lossless.png b/autotests/read/web= p/bw-cwebp-lossless.png deleted file mode 100644 index e2d506b..0000000 Binary files a/autotests/read/webp/bw-cwebp-lossless.png and /dev/null diff= er diff --git a/autotests/read/webp/bw-cwebp-lossless.webp b/autotests/read/we= bp/bw-cwebp-lossless.webp deleted file mode 100644 index 3567af1..0000000 Binary files a/autotests/read/webp/bw-cwebp-lossless.webp and /dev/null dif= fer diff --git a/autotests/read/webp/bw-cwebp.png b/autotests/read/webp/bw-cweb= p.png deleted file mode 100644 index ea9dcea..0000000 Binary files a/autotests/read/webp/bw-cwebp.png and /dev/null differ diff --git a/autotests/read/webp/bw-cwebp.webp b/autotests/read/webp/bw-cwe= bp.webp deleted file mode 100644 index 9c2e0c0..0000000 Binary files a/autotests/read/webp/bw-cwebp.webp and /dev/null differ diff --git a/autotests/read/webp/rgb-cwebp-lossless.png b/autotests/read/we= bp/rgb-cwebp-lossless.png deleted file mode 100644 index 267d678..0000000 Binary files a/autotests/read/webp/rgb-cwebp-lossless.png and /dev/null dif= fer diff --git a/autotests/read/webp/rgb-cwebp-lossless.webp b/autotests/read/w= ebp/rgb-cwebp-lossless.webp deleted file mode 100644 index 0151334..0000000 Binary files a/autotests/read/webp/rgb-cwebp-lossless.webp and /dev/null di= ffer diff --git a/autotests/read/webp/rgb-cwebp.png b/autotests/read/webp/rgb-cw= ebp.png deleted file mode 100644 index 528df3f..0000000 Binary files a/autotests/read/webp/rgb-cwebp.png and /dev/null differ diff --git a/autotests/read/webp/rgb-cwebp.webp b/autotests/read/webp/rgb-c= webp.webp deleted file mode 100644 index d889a9b..0000000 Binary files a/autotests/read/webp/rgb-cwebp.webp and /dev/null differ diff --git a/cmake/FindWebP.cmake b/cmake/FindWebP.cmake deleted file mode 100644 index 7aaa650..0000000 --- a/cmake/FindWebP.cmake +++ /dev/null @@ -1,203 +0,0 @@ -# Try to find the WebP library -# -# This will define: -# -# WebP_FOUND - True if WebP is available -# WebP_LIBRARIES - Link to these to use WebP -# WebP_INCLUDE_DIRS - Include directory for WebP -# WebP_DEFINITIONS - Compiler flags required to link against WebP -# -# In addition the following more fine grained variables will be defined: -# -# WebP_WebP_FOUND WebP_WebP_INCLUDE_DIR WebP_WebP_LIBRARY -# WebP_Decoder_FOUND WebP_Decoder_INCLUDE_DIR WebP_Decoder_LIBRA= RY -# WebP_DeMux_FOUND WebP_DeMux_INCLUDE_DIR WebP_DeMux_LIBRARY -# WebP_Mux_FOUND WebP_Mux_INCLUDE_DIR WebP_Mux_LIBRARY -# -# Additionally, the following imported targets will be defined: -# -# WebP::WebP -# WebP::Decoder -# WebP::DeMux -# WebP::Mux -# -# Note that the Decoder library provides a strict subset of the functional= ity -# of the WebP library; it is therefore not included in WebP_LIBRARIES (unl= ess -# the WebP library is not found), and you should not link to both WebP::We= bP -# and WebP::Decoder. -# -# Copyright (c) 2011 Fredrik H=C3=B6glund -# Copyright (c) 2013 Martin Gr=C3=A4=C3=9Flin -# Copyright (c) 2013-2014, Alex Merry, -# -# Redistribution and use is allowed according to the terms of the BSD lice= nse. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. - -if(${CMAKE_VERSION} VERSION_LESS 2.8.12) - message(FATAL_ERROR "CMake 2.8.12 is required by FindWebP.cmake") -endif() - -set(knownComponents - WebP - Decoder - DeMux - Mux) - -unset(unknownComponents) - -set(pkgConfigModules) -set(requiredComponents) - -if (WebP_FIND_COMPONENTS) - set(comps ${WebP_FIND_COMPONENTS}) -else() - set(comps ${knownComponents}) -endif() - -# iterate through the list of requested components, and check that we know= them all. -# If not, fail. -foreach(comp ${comps}) - list(FIND knownComponents ${comp} index ) - if("${index}" STREQUAL "-1") - list(APPEND unknownComponents "${comp}") - else() - if("${comp}" STREQUAL "WebP") - list(APPEND pkgConfigModules "libwebp") - elseif("${comp}" STREQUAL "Decoder") - list(APPEND pkgConfigModules "libwebpdecoder") - elseif("${comp}" STREQUAL "DeMux") - list(APPEND pkgConfigModules "libwebpdemux") - elseif("${comp}" STREQUAL "Mux") - list(APPEND pkgConfigModules "libwebpmux") - endif() - endif() -endforeach() - -if(DEFINED unknownComponents) - set(msgType STATUS) - if(WebP_FIND_REQUIRED) - set(msgType FATAL_ERROR) - endif() - if(NOT WebP_FIND_QUIETLY) - message(${msgType} "WebP: requested unknown components ${unknownComp= onents}") - endif() - return() -endif() - -macro(_WEBP_HANDLE_COMPONENT _comp) - set(_header) - set(_lib) - set(_pkgconfig_module) - if("${_comp}" STREQUAL "WebP") - set(_header "webp/encode.h") - set(_lib "webp") - set(_pkgconfig_module "libwebp") - elseif("${_comp}" STREQUAL "Decoder") - set(_header "webp/decode.h") - set(_lib "webpdecoder") - set(_pkgconfig_module "libwebpdecoder") - elseif("${_comp}" STREQUAL "DeMux") - set(_header "webp/demux.h") - set(_lib "webpdemux") - set(_pkgconfig_module "libwebpdemux") - elseif("${_comp}" STREQUAL "Mux") - set(_header "webp/mux.h") - set(_lib "webpmux") - set(_pkgconfig_module "libwebpmux") - endif() - - find_path(WebP_${_comp}_INCLUDE_DIR NAMES ${_header} HINTS ${PKG_WebP_= INCLUDE_DIRS}) - find_library(WebP_${_comp}_LIBRARY NAMES ${_lib} HINTS ${PKG_WebP_LIBR= ARY_DIRS}) - - if(WebP_${_comp}_INCLUDE_DIR AND WebP_${_comp}_LIBRARY) - if(NOT "${_comp}" STREQUAL "Decoder") - list(APPEND WebP_INCLUDE_DIRS ${WebP_${_comp}_INCLUDE_DIR}) - list(APPEND WebP_LIBRARIES ${WebP_${_comp}_LIBRARY}) - endif() - endif() - - if(PKG_WebP_VERSION AND NOT PKG_WebP_${_pkgconfig_module}_VERSION) - # this is what gets set if we only search for one module - set(WebP_${_comp}_VERSION_STRING "${PKG_WebP_VERSION}") - else() - set(WebP_${_comp}_VERSION_STRING "${PKG_WebP_${_pkgconfig_module}_= VERSION}") - endif() - if(NOT WebP_VERSION_STRING) - set(WebP_VERSION_STRING ${WebP_${_comp}_VERSION_STRING}) - endif() - - find_package_handle_standard_args(WebP_${_comp} - FOUND_VAR - WebP_${_comp}_FOUND - REQUIRED_VARS - WebP_${_comp}_LIBRARY - WebP_${_comp}_INCLUDE_DIR - VERSION_VAR - WebP_${_comp}_VERSION_STRING - ) - - mark_as_advanced(WebP_${_comp}_LIBRARY WebP_${_comp}_INCLUDE_DIR) - - # compatibility for old variable naming - set(WebP_${_comp}_INCLUDE_DIRS ${WebP_${_comp}_INCLUDE_DIR}) - set(WebP_${_comp}_LIBRARIES ${WebP_${_comp}_LIBRARY}) - - if(WebP_${_comp}_FOUND AND NOT TARGET WebP::${_comp}) - add_library(WebP::${_comp} UNKNOWN IMPORTED) - set_target_properties(WebP::${_comp} PROPERTIES - IMPORTED_LOCATION "${WebP_${_comp}_LIBRARY}" - INTERFACE_COMPILE_OPTIONS "${WebP_DEFINITIONS}" - INTERFACE_INCLUDE_DIRECTORIES "${WebP_${_comp}_INCLUDE_DIR}" - ) - endif() -endmacro() - -include(FindPackageHandleStandardArgs) -# Use pkg-config to get the directories and then use these values -# in the FIND_PATH() and FIND_LIBRARY() calls -find_package(PkgConfig) -pkg_check_modules(PKG_WebP QUIET ${pkgConfigModules}) - -set(WebP_DEFINITIONS ${PKG_WebP_CFLAGS}) - -foreach(comp ${comps}) - _webp_handle_component(${comp}) -endforeach() - -if (WebP_Decoder_FOUND AND NOT WebP_WebP_FOUND) - list(APPEND WebP_INCLUDE_DIRS ${WebP_Decoder_INCLUDE_DIR}) - list(APPEND WebP_LIBRARIES ${WebP_Decoder_LIBRARY}) -endif() - -if (WebP_INCLUDE_DIRS) - list(REMOVE_DUPLICATES WebP_INCLUDE_DIRS) -endif() - -if(WebP_WebP_FOUND) - if(WebP_DeMux_FOUND) - add_dependencies(WebP::DeMux WebP::WebP) - endif() - if(WebP_Mux_FOUND) - add_dependencies(WebP::Mux WebP::WebP) - endif() -endif() - -find_package_handle_standard_args(WebP - FOUND_VAR - WebP_FOUND - REQUIRED_VARS - WebP_LIBRARIES - WebP_INCLUDE_DIRS - VERSION_VAR - WebP_VERSION_STRING - HANDLE_COMPONENTS - ) - -# compatibility for old variable naming -set(WebP_INCLUDE_DIR ${WebP_INCLUDE_DIRS}) - -include(FeatureSummary) -set_package_properties(WebP PROPERTIES - URL http://www.openexr.com/ - DESCRIPTION "A library for handling WebP/VP8 image files") - diff --git a/src/imageformats/CMakeLists.txt b/src/imageformats/CMakeLists.= txt index 07ce79e..44f07dd 100644 --- a/src/imageformats/CMakeLists.txt +++ b/src/imageformats/CMakeLists.txt @@ -97,28 +97,6 @@ install(FILES tga.desktop DESTINATION ${SERVICES_INSTALL= _DIR}/qimageioplugins/) = ################################## = -if (WebP_FOUND) - add_library(kimg_webp MODULE webp.cpp) - target_link_libraries(kimg_webp Qt5::Gui WebP::WebP) - - install(TARGETS kimg_webp DESTINATION ${QT_PLUGIN_INSTALL_DIR}/imagef= ormats/) - install(FILES webp.desktop DESTINATION ${SERVICES_INSTALL_DIR}/qimagei= oplugins/) - - find_package(SharedMimeInfo) - set_package_properties(SharedMimeInfo PROPERTIES - # TODO: Make RUNTIME when we remove webp.xml - TYPE RECOMMENDED - PURPOSE "Required to install the WebP MIME Type information" - ) - if (SharedMimeInfo_FOUND) - # TODO: Remove when we can depend on shared-mime-info 1.3 - install(FILES webp.xml DESTINATION ${XDG_MIME_INSTALL_DIR} RENAME = kf5-imageformats-webp.xml) - update_xdg_mimetypes(${XDG_MIME_INSTALL_DIR}) - endif() -endif() - -################################## - add_library(kimg_xcf MODULE xcf.cpp) target_link_libraries(kimg_xcf Qt5::Gui) = diff --git a/src/imageformats/webp.cpp b/src/imageformats/webp.cpp deleted file mode 100644 index c92b7bb..0000000 --- a/src/imageformats/webp.cpp +++ /dev/null @@ -1,223 +0,0 @@ -/* -QImageIO Routines to read/write WebP images. - -Copyright (c) 2012,2013 Martin Koller - -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) version 3, or any -later version accepted by the membership of KDE e.V. (or its -successor approved by the membership of KDE e.V.), which shall -act as a proxy defined in Section 6 of version 3 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 library. If not, see . -*/ - -#include "webp.h" -#include -#include - -#include -#include - -//--------------------------------------------------------------------- - -WebPHandler::WebPHandler() - : quality(75) -{ -} - -//--------------------------------------------------------------------- - -bool WebPHandler::canRead() const -{ - if (canRead(device())) { - setFormat("webp"); - return true; - } - return false; -} - -//--------------------------------------------------------------------- - -bool WebPHandler::read(QImage *retImage) -{ - QByteArray data =3D device()->readAll(); - - WebPBitstreamFeatures features; - VP8StatusCode ret =3D WebPGetFeatures(reinterpret_cast= (data.constData()), data.size(), &features); - if ( ret !=3D VP8_STATUS_OK ) { - return false; - } - - if ( features.has_alpha ) { - *retImage =3D QImage(features.width, features.height, QImage::Form= at_ARGB32); - } else { - *retImage =3D QImage(features.width, features.height, QImage::Form= at_RGB32); - } - - if ( retImage->isNull() ) { // out of memory - return false; - } - -#if Q_BYTE_ORDER =3D=3D Q_BIG_ENDIAN - if ( WebPDecodeARGBInto(reinterpret_cast(data.constDat= a()), - data.size(), reinterpret_cast(retIma= ge->bits()), - retImage->byteCount(), retImage->bytesPerLine(= )) =3D=3D 0 ) { - return false; - } -#else - if ( WebPDecodeBGRAInto(reinterpret_cast(data.constDat= a()), - data.size(), reinterpret_cast(retIma= ge->bits()), - retImage->byteCount(), retImage->bytesPerLine(= )) =3D=3D 0 ) { - return false; - } -#endif - - return true; -} - -//--------------------------------------------------------------------- - -bool WebPHandler::write(const QImage &image) -{ - // limitation in WebP - if ( (image.height() > 16383) || (image.height() =3D=3D 0) || - (image.width() > 16383) || (image.width() =3D=3D 0) ) - return false; - - uint8_t *imageData =3D new uint8_t[image.width() * image.height() * (3= + image.hasAlphaChannel())]; - - size_t idx =3D 0; - for (int y =3D 0; y < image.height(); y++) { - const QRgb *scanline =3D reinterpret_cast(image.const= ScanLine(y)); - for (int x =3D 0; x < image.width(); x++) { - imageData[idx++] =3D qRed(scanline[x]); - imageData[idx++] =3D qGreen(scanline[x]); - imageData[idx++] =3D qBlue(scanline[x]); - - if ( image.hasAlphaChannel() ) { - imageData[idx++] =3D qAlpha(scanline[x]); - } - } - } - - uint8_t *output =3D 0; - size_t size; - if ( image.hasAlphaChannel() ) { - size =3D WebPEncodeRGBA(imageData, image.width(), image.height(), = image.width() * 4, quality, &output); - } else { - size =3D WebPEncodeRGB(imageData, image.width(), image.height(), i= mage.width() * 4, quality, &output); - } - delete [] imageData; - - if ( size =3D=3D 0 ) { - free(output); - return false; - } - - device()->write(reinterpret_cast(output), size); - free(output); - - return true; -} - -//--------------------------------------------------------------------- - -bool WebPHandler::supportsOption(ImageOption option) const -{ - return (option =3D=3D Quality) || (option =3D=3D Size); -} - -//--------------------------------------------------------------------- - -QVariant WebPHandler::option(ImageOption option) const -{ - switch ( option ) - { - case Quality: - return quality; - - case Size: { - QByteArray data =3D device()->peek(26); - - int width =3D 0, height =3D 0; - - if ( WebPGetInfo(reinterpret_cast(data.constDa= ta()), - data.size(), &width, &height) =3D=3D 0 ) - return QSize(); // header error - - return QSize(width, height); - } - - default: return QVariant(); - } -} - -//--------------------------------------------------------------------- - -void WebPHandler::setOption(ImageOption option, const QVariant &value) -{ - if (option =3D=3D Quality) - quality =3D qBound(0, value.toInt(), 100); -} - -//--------------------------------------------------------------------- - -bool WebPHandler::canRead(QIODevice *device) -{ - if (!device) { - qWarning("WebPHandler::canRead() called with no device"); - return false; - } - - // WebP file header: 4 bytes "RIFF", 4 bytes length, 4 bytes "WEBP" - QByteArray header =3D device->peek(12); - - return (header.size() =3D=3D 12) && header.startsWith("RIFF") && heade= r.endsWith("WEBP"); -} - -//--------------------------------------------------------------------- -//--------------------------------------------------------------------- - -QImageIOPlugin::Capabilities WebPPlugin::capabilities(QIODevice *device, c= onst QByteArray &format) const -{ - // this plugin produces webp images it cannot read at the moment, - // so do not claim to be able to write - if (format =3D=3D "webp") - return Capabilities(CanRead); - //return Capabilities(CanRead | CanWrite); - if (!format.isEmpty()) - return 0; - if (!device->isOpen()) - return 0; - - Capabilities cap; - if (device->isReadable() && WebPHandler::canRead(device)) - cap |=3D CanRead; - /* - if (device->isWritable()) - cap |=3D CanWrite; - */ - return cap; -} - -//--------------------------------------------------------------------- - -QImageIOHandler *WebPPlugin::create(QIODevice *device, const QByteArray &f= ormat) const -{ - QImageIOHandler *handler =3D new WebPHandler; - handler->setDevice(device); - handler->setFormat(format); - return handler; -} - -//--------------------------------------------------------------------- - diff --git a/src/imageformats/webp.desktop b/src/imageformats/webp.desktop deleted file mode 100644 index 3526be5..0000000 --- a/src/imageformats/webp.desktop +++ /dev/null @@ -1,7 +0,0 @@ -[Desktop Entry] -Type=3DService -X-KDE-ServiceTypes=3DQImageIOPlugins -X-KDE-ImageFormat=3Dwebp -X-KDE-MimeType=3Dimage/x-webp -X-KDE-Read=3Dtrue -X-KDE-Write=3Dtrue diff --git a/src/imageformats/webp.h b/src/imageformats/webp.h deleted file mode 100644 index 91e724e..0000000 --- a/src/imageformats/webp.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -QImageIO Routines to read/write WebP images. - -Copyright (c) 2012,2013 Martin Koller - -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) version 3, or any -later version accepted by the membership of KDE e.V. (or its -successor approved by the membership of KDE e.V.), which shall -act as a proxy defined in Section 6 of version 3 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 library. If not, see . -*/ - -#ifndef WEBP_H -#define WEBP_H - -#include - -class WebPHandler : public QImageIOHandler -{ -public: - WebPHandler(); - - bool canRead() const Q_DECL_OVERRIDE; - bool read(QImage *image) Q_DECL_OVERRIDE; - bool write(const QImage &image) Q_DECL_OVERRIDE; - - bool supportsOption(ImageOption option) const Q_DECL_OVERRIDE; - QVariant option(ImageOption option) const Q_DECL_OVERRIDE; - void setOption(ImageOption option, const QVariant &value) Q_DECL_OVERR= IDE; - - static bool canRead(QIODevice *device); - -private: - int quality; -}; - -class WebPPlugin : public QImageIOPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterfa= ce" FILE "webp.json") - -public: - Capabilities capabilities(QIODevice *device, const QByteArray &format)= const Q_DECL_OVERRIDE; - QImageIOHandler *create(QIODevice *device, const QByteArray &format = =3D QByteArray()) const Q_DECL_OVERRIDE; -}; - -#endif diff --git a/src/imageformats/webp.json b/src/imageformats/webp.json deleted file mode 100644 index 9e81ff9..0000000 --- a/src/imageformats/webp.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "Keys": [ "webp" ], - "MimeTypes": [ "image/x-webp" ] -} diff --git a/src/imageformats/webp.xml b/src/imageformats/webp.xml deleted file mode 100644 index 68ddbbf..0000000 --- a/src/imageformats/webp.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - WebP image - - - - - - - - -