Hello community,
here is the log from the commit of package kimageformats for openSUSE:Factory checked in at 2014-04-02 17:22:08
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/kimageformats (Old)
and /work/SRC/openSUSE:Factory/.kimageformats.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "kimageformats"
Changes:
--------
--- /work/SRC/openSUSE:Factory/kimageformats/kimageformats.changes 2014-03-10 12:17:30.000000000 +0100
+++ /work/SRC/openSUSE:Factory/.kimageformats.new/kimageformats.changes 2014-04-02 17:22:18.000000000 +0200
@@ -1,0 +2,9 @@
+Sat Mar 29 19:47:41 UTC 2014 - hrvoje.senjan@gmail.com
+
+- Update to 4.98.0
+ * API improvements and cleanups
+ * Buildsystem fixes
+ * For more details please see:
+ http://www.kde.org/announcements/announce-frameworks5-beta1.php
+
+-------------------------------------------------------------------
Old:
----
kimageformats-4.97.0.tar.xz
New:
----
kimageformats-4.98.0.tar.xz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ kimageformats.spec ++++++
--- /var/tmp/diff_new_pack.wgQ6gs/_old 2014-04-02 17:22:19.000000000 +0200
+++ /var/tmp/diff_new_pack.wgQ6gs/_new 2014-04-02 17:22:19.000000000 +0200
@@ -17,10 +17,10 @@
Name: kimageformats
-Version: 4.97.0
+Version: 4.98.0
Release: 0
BuildRequires: cmake >= 2.8.12
-BuildRequires: extra-cmake-modules >= 0.0.11
+BuildRequires: extra-cmake-modules >= 0.0.12
BuildRequires: fdupes
BuildRequires: kf5-filesystem
BuildRequires: libjasper-devel
++++++ kimageformats-4.97.0.tar.xz -> kimageformats-4.98.0.tar.xz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kimageformats-4.97.0/CMakeLists.txt new/kimageformats-4.98.0/CMakeLists.txt
--- old/kimageformats-4.97.0/CMakeLists.txt 2014-03-01 15:49:38.000000000 +0100
+++ new/kimageformats-4.98.0/CMakeLists.txt 2014-03-28 19:17:00.000000000 +0100
@@ -2,9 +2,9 @@
project(KImageFormats)
-find_package(ECM 0.0.11 REQUIRED NO_MODULE)
+find_package(ECM 0.0.12 REQUIRED NO_MODULE)
-set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
+set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
include(KDEInstallDirs)
include(KDEFrameworkCompilerSettings)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kimageformats-4.97.0/autotests/CMakeLists.txt new/kimageformats-4.98.0/autotests/CMakeLists.txt
--- old/kimageformats-4.97.0/autotests/CMakeLists.txt 2014-03-01 15:49:38.000000000 +0100
+++ new/kimageformats-4.98.0/autotests/CMakeLists.txt 2014-03-28 19:17:00.000000000 +0100
@@ -1,11 +1,18 @@
#find_package(Qt5Test ${REQUIRED_QT_VERSION} NO_MODULE)
include(ECMMarkAsTest)
+include(CMakeParseArguments)
add_definitions(-DPLUGIN_DIR="${CMAKE_CURRENT_BINARY_DIR}/../src")
remove_definitions(-DQT_NO_CAST_FROM_ASCII)
macro(kimageformats_read_tests)
+ cmake_parse_arguments(KIF_RT "" "FUZZ" "" ${ARGN})
+ set(_fuzzarg)
+ if (KIF_RT_FUZZ)
+ set(_fuzzarg -f ${KIF_RT_FUZZ})
+ endif()
+
if (NOT TARGET readtest)
add_executable(readtest readtest.cpp)
target_link_libraries(readtest Qt5::Gui)
@@ -13,10 +20,11 @@
PRIVATE IMAGEDIR="${CMAKE_CURRENT_SOURCE_DIR}/read")
ecm_mark_as_test(readtest)
endif()
- foreach(_testname ${ARGN})
+
+ foreach(_testname ${KIF_RT_UNPARSED_ARGUMENTS})
add_test(
NAME kimageformats-read-${_testname}
- COMMAND readtest ${_testname}
+ COMMAND readtest ${_fuzzarg} ${_testname}
)
endforeach(_testname)
endmacro()
@@ -53,6 +61,10 @@
ras
rgb
tga
+)
+# Allow some fuzziness when reading this formats, to allow for
+# rounding errors (eg: in alpha blending).
+kimageformats_read_tests(FUZZ 1
xcf
)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kimageformats-4.97.0/autotests/readtest.cpp new/kimageformats-4.98.0/autotests/readtest.cpp
--- old/kimageformats-4.97.0/autotests/readtest.cpp 2014-03-01 15:49:38.000000000 +0100
+++ new/kimageformats-4.98.0/autotests/readtest.cpp 2014-03-28 19:17:00.000000000 +0100
@@ -29,6 +29,8 @@
#include <QImageReader>
#include <QTextStream>
+#include "../tests/format-enum.h"
+
static void writeImageData(const char *name, const QString &filename, const QImage &image)
{
QFile file(filename);
@@ -49,6 +51,27 @@
}
}
+// allow each byte to be different by up to 1, to allow for rounding errors
+static bool fuzzyeq(const QImage &im1, const QImage &im2, uchar fuzziness)
+{
+ const int height = im1.height();
+ const int width = im1.width();
+ for (int i = 0; i < height; ++i) {
+ const uchar *line1 = im1.scanLine(i);
+ const uchar *line2 = im2.scanLine(i);
+ for (int j = 0; j < width; ++j) {
+ if (line1[j] > line2[j]) {
+ if (line1[j] - line2[j] > fuzziness)
+ return false;
+ } else {
+ if (line2[j] - line1[j] > fuzziness)
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
int main(int argc, char ** argv)
{
QCoreApplication app(argc, argv);
@@ -61,6 +84,11 @@
parser.addHelpOption();
parser.addVersionOption();
parser.addPositionalArgument(QStringLiteral("format"), QStringLiteral("format to test"));
+ QCommandLineOption fuzz(
+ QStringList() << QStringLiteral("f") << QStringLiteral("fuzz"),
+ QStringLiteral("Allow for some deviation in ARGB data."),
+ QStringLiteral("max"));
+ parser.addOption(fuzz);
parser.process(app);
@@ -73,6 +101,17 @@
parser.showHelp(1);
}
+ uchar fuzziness = 0;
+ if (parser.isSet(fuzz)) {
+ bool ok;
+ uint fuzzarg = parser.value(fuzz).toUInt(&ok);
+ if (!ok || fuzzarg > 255) {
+ QTextStream(stderr) << "Error: max fuzz argument must be a number between 0 and 255\n";
+ parser.showHelp(1);
+ }
+ fuzziness = uchar(fuzzarg);
+ }
+
QString suffix = args.at(0);
QByteArray format = suffix.toLatin1();
@@ -115,20 +154,47 @@
++failed;
continue;
}
- inputImage = inputImage.convertToFormat(expImage.format());
- if (expImage != inputImage) {
+ if (expImage.width() != inputImage.width()) {
+ QTextStream(stdout) << "FAIL : " << fi.fileName()
+ << ": width was " << inputImage.width()
+ << " but " << expfilename << " width was "
+ << expImage.width() << "\n";
+ ++failed;
+ } else if (expImage.height() != inputImage.height()) {
QTextStream(stdout) << "FAIL : " << fi.fileName()
- << ": differs from " << expfilename << "\n";
- writeImageData("expected data",
- fi.fileName() + QLatin1String("-expected.data"),
- expImage);
- writeImageData("actual data",
- fi.fileName() + QLatin1String("-actual.data"),
- inputImage);
+ << ": height was " << inputImage.height()
+ << " but " << expfilename << " height was "
+ << expImage.height() << "\n";
++failed;
} else {
- QTextStream(stdout) << "PASS : " << fi.fileName() << "\n";
- ++passed;
+ if (inputImage.format() != QImage::Format_ARGB32) {
+ QTextStream(stdout) << "INFO : " << fi.fileName()
+ << ": converting " << fi.fileName()
+ << " from " << formatToString(inputImage.format())
+ << " to ARGB32\n";
+ inputImage = inputImage.convertToFormat(QImage::Format_ARGB32);
+ }
+ if (expImage.format() != QImage::Format_ARGB32) {
+ QTextStream(stdout) << "INFO : " << fi.fileName()
+ << ": converting " << expfilename
+ << " from " << formatToString(expImage.format())
+ << " to ARGB32\n";
+ expImage = expImage.convertToFormat(QImage::Format_ARGB32);
+ }
+ if (fuzzyeq(inputImage, expImage, fuzziness)) {
+ QTextStream(stdout) << "PASS : " << fi.fileName() << "\n";
+ ++passed;
+ } else {
+ QTextStream(stdout) << "FAIL : " << fi.fileName()
+ << ": differs from " << expfilename << "\n";
+ writeImageData("expected data",
+ fi.fileName() + QLatin1String("-expected.data"),
+ expImage);
+ writeImageData("actual data",
+ fi.fileName() + QLatin1String("-actual.data"),
+ inputImage);
+ ++failed;
+ }
}
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kimageformats-4.97.0/cmake/FindOpenEXR.cmake new/kimageformats-4.98.0/cmake/FindOpenEXR.cmake
--- old/kimageformats-4.97.0/cmake/FindOpenEXR.cmake 2014-03-01 15:49:38.000000000 +0100
+++ new/kimageformats-4.98.0/cmake/FindOpenEXR.cmake 1970-01-01 01:00:00.000000000 +0100
@@ -1,144 +0,0 @@
-# Try to find the OpenEXR libraries
-#
-# This will define:
-#
-# OpenEXR_FOUND - True if OpenEXR is available
-# OpenEXR_LIBRARIES - Link to these to use OpenEXR
-# OpenEXR_INCLUDE_DIRS - Include directory for OpenEXR
-# OpenEXR_DEFINITIONS - Compiler flags required to link against OpenEXR
-# OpenEXR::IlmImf - imported target to link against (instead of using the above variables)
-#
-
-
-# Copyright (c) 2006, Alexander Neundorf,
-# Copyright (c) 2013-2014, Alex Merry,
-#
-# 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 copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-# 3. The name of the author may not be used to endorse or promote products
-# derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
-
-
-if(${CMAKE_VERSION} VERSION_LESS 2.8.12)
- message(FATAL_ERROR "CMake 2.8.12 is required by FindOpenEXR.cmake")
-endif()
-
-# 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(PC_OpenEXR QUIET OpenEXR)
-
-set(OpenEXR_DEFINITIONS ${PC_OpenEXR_CFLAGS_OTHER})
-
-find_path(OpenEXR_INCLUDE_DIR ImfRgbaFile.h
- PATHS
- ${PC_OpenEXR_INCLUDEDIR}
- ${PC_OpenEXR_INCLUDE_DIRS}
- PATH_SUFFIXES OpenEXR
-)
-
-# Required libraries for OpenEXR
-find_library(OpenEXR_HALF_LIBRARY NAMES Half
- PATHS
- ${PC_OpenEXR_LIBDIR}
- ${PC_OpenEXR_LIBRARY_DIRS}
-)
-find_library(OpenEXR_IEX_LIBRARY NAMES Iex
- PATHS
- ${PC_OpenEXR_LIBDIR}
- ${PC_OpenEXR_LIBRARY_DIRS}
-)
-find_library(OpenEXR_IMATH_LIBRARY NAMES Imath
- PATHS
- ${PC_OpenEXR_LIBDIR}
- ${PC_OpenEXR_LIBRARY_DIRS}
-)
-find_library(OpenEXR_ILMTHREAD_LIBRARY NAMES IlmThread
- PATHS
- ${PC_OpenEXR_LIBDIR}
- ${PC_OpenEXR_LIBRARY_DIRS}
-)
-# This is the actual OpenEXR library
-find_library(OpenEXR_ILMIMF_LIBRARY NAMES IlmImf
- PATHS
- ${PC_OpenEXR_LIBDIR}
- ${PC_OpenEXR_LIBRARY_DIRS}
-)
-
-set(_OpenEXR_deps
- ${OpenEXR_HALF_LIBRARY}
- ${OpenEXR_IEX_LIBRARY}
- ${OpenEXR_IMATH_LIBRARY}
- ${OpenEXR_ILMTHREAD_LIBRARY})
-
-set(OpenEXR_LIBRARIES
- ${_OpenEXR_deps}
- ${OpenEXR_ILMIMF_LIBRARY})
-
-if (OpenEXR_INCLUDE_DIR AND EXISTS "${OpenEXR_INCLUDE_DIR}/OpenEXRConfig.h")
- file(STRINGS "${OpenEXR_INCLUDE_DIR}/OpenEXRConfig.h" openexr_version_str
- REGEX "^#define[\t ]+OPENEXR_VERSION_STRING[\t ]+\"[^\"]*\"")
- string(REGEX REPLACE "^#define[\t ]+OPENEXR_VERSION_STRING[\t ]+\"([^\"]*).*"
- "\\1" OpenEXR_VERSION_STRING "${openexr_version_str}")
- unset(openexr_version_str)
-endif ()
-
-include(FindPackageHandleStandardArgs)
-# find_package_handle_standard_args reports the value of the first variable
-# on success, so make sure this is the actual OpenEXR library
-find_package_handle_standard_args(OpenEXR
- FOUND_VAR OpenEXR_FOUND
- REQUIRED_VARS
- OpenEXR_ILMIMF_LIBRARY
- OpenEXR_HALF_LIBRARY
- OpenEXR_IEX_LIBRARY
- OpenEXR_IMATH_LIBRARY
- OpenEXR_ILMTHREAD_LIBRARY
- OpenEXR_INCLUDE_DIR
- VERSION_VAR OpenEXR_VERSION_STRING)
-
-set(OpenEXR_INCLUDE_DIRS ${OpenEXR_INCLUDE_DIR})
-
-include(FeatureSummary)
-set_package_properties(OpenEXR PROPERTIES
- URL http://www.openexr.com/
- DESCRIPTION "A library for handling OpenEXR high dynamic-range image files")
-
-mark_as_advanced(
- OpenEXR_INCLUDE_DIR
- OpenEXR_LIBRARIES
- OpenEXR_DEFINITIONS
- OpenEXR_ILMIMF_LIBRARY
- OpenEXR_ILMTHREAD_LIBRARY
- OpenEXR_IMATH_LIBRARY
- OpenEXR_IEX_LIBRARY
- OpenEXR_HALF_LIBRARY
-)
-
-if(OpenEXR_FOUND AND NOT TARGET OpenEXR::IlmImf)
- add_library(OpenEXR::IlmImf UNKNOWN IMPORTED)
- set_target_properties(OpenEXR::IlmImf PROPERTIES
- IMPORTED_LOCATION "${OpenEXR_ILMIMF_LIBRARY}"
- INTERFACE_COMPILE_OPTIONS "${OpenEXR_DEFINITIONS}"
- INTERFACE_INCLUDE_DIRECTORIES "${OpenEXR_INCLUDE_DIR}"
- INTERFACE_LINK_LIBRARIES "${_OpenEXR_deps}"
- )
-endif()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kimageformats-4.97.0/tests/CMakeLists.txt new/kimageformats-4.98.0/tests/CMakeLists.txt
--- old/kimageformats-4.97.0/tests/CMakeLists.txt 2014-03-01 15:49:38.000000000 +0100
+++ new/kimageformats-4.98.0/tests/CMakeLists.txt 2014-03-28 19:17:00.000000000 +0100
@@ -12,4 +12,5 @@
kimageformats_executable_tests(
imageconverter
+ imagedump
)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kimageformats-4.97.0/tests/format-enum.h new/kimageformats-4.98.0/tests/format-enum.h
--- old/kimageformats-4.97.0/tests/format-enum.h 1970-01-01 01:00:00.000000000 +0100
+++ new/kimageformats-4.98.0/tests/format-enum.h 2014-03-28 19:17:00.000000000 +0100
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2014 Alex Merry
+ *
+ * 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
+ * http://www.gnu.org/licenses/.
+ */
+
+#include <QImage>
+
+// Generated from QImage::Format enum
+static const char * qimage_format_enum_names[] = {
+ "Invalid",
+ "Mono",
+ "MonoLSB",
+ "Indexed8",
+ "RGB32",
+ "ARGB32",
+ "ARGB32_Premultiplied",
+ "RGB16",
+ "ARGB8565_Premultiplied",
+ "RGB666",
+ "ARGB6666_Premultiplied",
+ "RGB555",
+ "ARGB8555_Premultiplied",
+ "RGB888",
+ "RGB444",
+ "ARGB4444_Premultiplied",
+ "RGBX8888",
+ "RGBA8888",
+ "RGBA8888_Premultiplied"
+};
+// Never claim there are more than QImage::NImageFormats supported formats.
+// This is future-proofing against the above list being extended.
+static const int qimage_format_enum_names_count =
+ (sizeof(qimage_format_enum_names) / sizeof(*qimage_format_enum_names) > int(QImage::NImageFormats))
+ ? int(QImage::NImageFormats)
+ : (sizeof(qimage_format_enum_names) / sizeof(*qimage_format_enum_names));
+
+QImage::Format formatFromString(const QString &str)
+{
+ for (int i = 0; i < qimage_format_enum_names_count; ++i) {
+ if (str.compare(QLatin1String(qimage_format_enum_names[i]), Qt::CaseInsensitive) == 0) {
+ return (QImage::Format)(i);
+ }
+ }
+ return QImage::Format_Invalid;
+}
+
+QString formatToString(QImage::Format format)
+{
+ int index = int(format);
+ if (index > 0 && index < qimage_format_enum_names_count) {
+ return QLatin1String(qimage_format_enum_names[index]);
+ }
+ return QLatin1String("");
+}
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kimageformats-4.97.0/tests/imagedump.cpp new/kimageformats-4.98.0/tests/imagedump.cpp
--- old/kimageformats-4.97.0/tests/imagedump.cpp 1970-01-01 01:00:00.000000000 +0100
+++ new/kimageformats-4.98.0/tests/imagedump.cpp 2014-03-28 19:17:00.000000000 +0100
@@ -0,0 +1,128 @@
+/*
+ * Copyright 2013 Alex Merry
+ *
+ * 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
+ * http://www.gnu.org/licenses/.
+ */
+
+#include
+
+#include <QCommandLineOption>
+#include <QCommandLineParser>
+#include <QCoreApplication>
+#include <QDebug>
+#include <QImageReader>
+#include <QFile>
+#include <QMetaObject>
+#include <QMetaEnum>
+#include <QTextStream>
+
+#include "format-enum.h"
+
+int main(int argc, char **argv)
+{
+ QCoreApplication app(argc, argv);
+ QCoreApplication::addLibraryPath(QStringLiteral(PLUGIN_DIR));
+ QCoreApplication::setApplicationName(QStringLiteral("imagedump"));
+ QCoreApplication::setApplicationVersion(QStringLiteral("1.0.0.0"));
+
+ QCommandLineParser parser;
+ parser.setApplicationDescription(QStringLiteral("Dumps the content of QImage::bits()"));
+ parser.addHelpOption();
+ parser.addVersionOption();
+ parser.addPositionalArgument(QStringLiteral("image"), QStringLiteral("image file"));
+ parser.addPositionalArgument(QStringLiteral("datafile"), QStringLiteral("file QImage data should be written to"));
+ QCommandLineOption informat(
+ QStringList() << QStringLiteral("f") << QStringLiteral("file-format"),
+ QStringLiteral("Image file format"),
+ QStringLiteral("format"));
+ parser.addOption(informat);
+ QCommandLineOption qimgformat(
+ QStringList() << QStringLiteral("q") << QStringLiteral("qimage-format"),
+ QStringLiteral("QImage data format"),
+ QStringLiteral("format"));
+ parser.addOption(qimgformat);
+ QCommandLineOption listformats(
+ QStringList() << QStringLiteral("l") << QStringLiteral("list-file-formats"),
+ QStringLiteral("List supported image file formats"));
+ parser.addOption(listformats);
+ QCommandLineOption listqformats(
+ QStringList() << QStringLiteral("p") << QStringLiteral("list-qimage-formats"),
+ QStringLiteral("List supported QImage data formats"));
+ parser.addOption(listqformats);
+
+ parser.process(app);
+
+ const QStringList files = parser.positionalArguments();
+
+ if (parser.isSet(listformats)) {
+ QTextStream out(stdout);
+ out << "File formats:\n";
+ foreach (const QByteArray &fmt, QImageReader::supportedImageFormats()) {
+ out << " " << fmt << '\n';
+ }
+ return 0;
+ }
+ if (parser.isSet(listqformats)) {
+ QTextStream out(stdout);
+ out << "QImage formats:\n";
+ // skip QImage::Format_Invalid
+ for (int i = 1; i < qimage_format_enum_names_count; ++i) {
+ out << " " << qimage_format_enum_names[i] << '\n';
+ }
+ return 0;
+ }
+
+ if (files.count() != 2) {
+ QTextStream(stderr) << "Must provide exactly two files\n";
+ parser.showHelp(1);
+ }
+ QImageReader reader(files.at(0), parser.value(informat).toLatin1());
+ QImage img = reader.read();
+ if (img.isNull()) {
+ QTextStream(stderr) << "Could not read image: "
+ << reader.errorString() << '\n';
+ return 2;
+ }
+
+ QFile output(files.at(1));
+ if (!output.open(QIODevice::WriteOnly)) {
+ QTextStream(stderr) << "Could not open " << files.at(1)
+ << " for writing: "
+ << output.errorString() << '\n';
+ return 3;
+ }
+ if (parser.isSet(qimgformat)) {
+ QImage::Format qformat = formatFromString(parser.value(qimgformat));
+ if (qformat == QImage::Format_Invalid) {
+ QTextStream(stderr) << "Unknown QImage data format "
+ << parser.value(qimgformat) << '\n';
+ return 4;
+ }
+ img = img.convertToFormat(qformat);
+ }
+ qint64 written = output.write(reinterpret_cast(img.bits()), img.byteCount());
+ if (written != img.byteCount()) {
+ QTextStream(stderr) << "Could not write image data to " << files.at(1)
+ << ":" << output.errorString() << "\n";
+ return 5;
+ }
+ QTextStream(stdout) << "Created " << files.at(1) << " with data format "
+ << formatToString(img.format()) << "\n";
+
+ return 0;
+}
--
To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-commit+help@opensuse.org