Git commit 9c8c7278d16ba422de31b225c9b25bb31f07036c by Alex Merry. Committed on 20/02/2014 at 13:22. Pushed by alexmerry into branch 'frameworks'. Remove webp QImageIO plugin This is now in kimageformats M +0 -1 CMakeLists.txt D +0 -22 kimgio/CMakeLists.txt D +0 -246 kimgio/webp.cpp D +0 -7 kimgio/webp.desktop D +0 -49 kimgio/webp.h D +0 -7 kimgio/webp.xml http://commits.kde.org/kde-runtime/9c8c7278d16ba422de31b225c9b25bb31f07036c diff --git a/CMakeLists.txt b/CMakeLists.txt index 733f827..45dcde6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -164,7 +164,6 @@ endif ( NOT WINCE ) add_subdirectory(kioslave) # add_subdirectory(kurifilter-plugins) # add_subdirectory(phonon) -# add_subdirectory(kimgio) # macro_optional_add_subdirectory(renamedlgplugins) = # UI Helper applications diff --git a/kimgio/CMakeLists.txt b/kimgio/CMakeLists.txt deleted file mode 100644 index 62ee117..0000000 --- a/kimgio/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -project(runtime_kimgio) - -find_package(KDE4 REQUIRED) -include(KDE4Defaults) - -################################## -# WebP image IO support - -find_library(FOUND_WEBP webp) -if ( FOUND_WEBP ) - set(kimg_webp_LIB_SRCS webp.cpp) - kde4_add_plugin(kimg_webp ${kimg_webp_LIB_SRCS}) - target_link_libraries(kimg_webp ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY}= webp) - - install(TARGETS kimg_webp DESTINATION ${PLUGIN_INSTALL_DIR}/plugins/ima= geformats/) - install(FILES webp.desktop DESTINATION ${SERVICES_INSTALL_DIR}/qimageiop= lugins/) - - find_package(SharedMimeInfo REQUIRED) - install(FILES webp.xml DESTINATION ${XDG_MIME_INSTALL_DIR}) - update_xdg_mimetypes(${XDG_MIME_INSTALL_DIR}) -endif() - diff --git a/kimgio/webp.cpp b/kimgio/webp.cpp deleted file mode 100644 index d51c1ea..0000000 --- a/kimgio/webp.cpp +++ /dev/null @@ -1,246 +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 - -#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; -} - -//--------------------------------------------------------------------- - -QByteArray WebPHandler::format() const -{ - return "webp"; -} - -//--------------------------------------------------------------------- - -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"); -} - -//--------------------------------------------------------------------- -//--------------------------------------------------------------------- - -class WebPPlugin : public QImageIOPlugin -{ -public: - QStringList keys() const; - Capabilities capabilities(QIODevice *device, const QByteArray &format)= const; - QImageIOHandler *create(QIODevice *device, const QByteArray &format = =3D QByteArray()) const; -}; - -//--------------------------------------------------------------------- - -QStringList WebPPlugin::keys() const -{ - return QStringList() << "webp"; -} - -//--------------------------------------------------------------------- - -QImageIOPlugin::Capabilities WebPPlugin::capabilities(QIODevice *device, c= onst QByteArray &format) const -{ - if (format =3D=3D "webp") - 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; -} - -//--------------------------------------------------------------------- - -Q_EXPORT_STATIC_PLUGIN(WebPPlugin) -Q_EXPORT_PLUGIN2(webp, WebPPlugin) diff --git a/kimgio/webp.desktop b/kimgio/webp.desktop deleted file mode 100644 index 3526be5..0000000 --- a/kimgio/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/kimgio/webp.h b/kimgio/webp.h deleted file mode 100644 index a58d1f1..0000000 --- a/kimgio/webp.h +++ /dev/null @@ -1,49 +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(); - - virtual bool canRead() const; - virtual bool read(QImage *image); - virtual bool write(const QImage &image); - - virtual QByteArray format() const; - - virtual bool supportsOption(ImageOption option) const; - virtual QVariant option(ImageOption option) const; - virtual void setOption(ImageOption option, const QVariant &value); - - static bool canRead(QIODevice *device); - -private: - int quality; -}; - -#endif diff --git a/kimgio/webp.xml b/kimgio/webp.xml deleted file mode 100644 index 4246f76..0000000 --- a/kimgio/webp.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - WebP image - - -