Implement fuzzy image matching in readtest

Images are converted to ARGB32 format, then each byte (ie: each pixel
channel) in the read image is allowed to deviate by some specified
amount from the corresponding byte in the expected image, to allow for
rounding errors etc.

By default, no deviation is permitted, but the XCF tests are allowed a
deviation of 1, as the alpha blending can result in rounding errors
(depending on whether hardware acceleration is used, for example).  In
the end, we are not too concerned about a small deviation that is
invisible to the human eye.

REVIEW: 116567
This commit is contained in:
Alex Merry
2014-03-03 12:57:50 +00:00
parent 895305050c
commit 0f795e6625
2 changed files with 91 additions and 13 deletions

View File

@ -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 @@ macro(kimageformats_read_tests)
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 @@ kimageformats_read_tests(
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
)