From 32eabbc5534dd1dc867dfe0967446a17ae8be0cc Mon Sep 17 00:00:00 2001 From: Dirk Stolle Date: Tue, 23 Jul 2024 09:40:16 +0200 Subject: [PATCH 1/3] chore: fix more typos (#753) --- doc/tutorial/histogram.rst | 2 +- .../gil/extension/io/jpeg/detail/write.hpp | 4 +- .../gil/extension/io/tiff/detail/read.hpp | 2 +- .../io/tiff/detail/scanline_read.hpp | 2 +- .../boost/gil/image_processing/convolve.hpp | 2 +- .../image_processing/histogram_matching.hpp | 4 +- .../boost/gil/image_processing/threshold.hpp | 2 +- .../io/tiff/tiff_file_format_test.cpp | 54 +++++++++---------- 8 files changed, 36 insertions(+), 36 deletions(-) diff --git a/doc/tutorial/histogram.rst b/doc/tutorial/histogram.rst index 4ce849edd4..0701c5a857 100644 --- a/doc/tutorial/histogram.rst +++ b/doc/tutorial/histogram.rst @@ -7,7 +7,7 @@ Tutorial: Histogram This is a short tutorial presenting an example of a very simple sample of code from an existing code base that calculates histogram of an image. -Next, the program is rewritten using GIL featres. +Next, the program is rewritten using GIL features. Original implementation ----------------------- diff --git a/include/boost/gil/extension/io/jpeg/detail/write.hpp b/include/boost/gil/extension/io/jpeg/detail/write.hpp index e4534b3d58..35ac8b72c8 100644 --- a/include/boost/gil/extension/io/jpeg/detail/write.hpp +++ b/include/boost/gil/extension/io/jpeg/detail/write.hpp @@ -103,7 +103,7 @@ class writer< Device , TRUE ); - // Needs to be done after jpeg_set_defaults() since it's overridding this value back to slow. + // Needs to be done after jpeg_set_defaults() since it's overriding this value back to slow. this->get()->dct_method = this->_info._dct_method; @@ -138,7 +138,7 @@ class writer< Device }; /// -/// JPEG Dyamic Image Writer +/// JPEG Dynamic Image Writer /// template< typename Device > class dynamic_image_writer< Device diff --git a/include/boost/gil/extension/io/tiff/detail/read.hpp b/include/boost/gil/extension/io/tiff/detail/read.hpp index 13ce23d618..1424e2f7f0 100644 --- a/include/boost/gil/extension/io/tiff/detail/read.hpp +++ b/include/boost/gil/extension/io/tiff/detail/read.hpp @@ -277,7 +277,7 @@ class reader< Device break; } - case PHOTOMETRIC_SEPARATED: // CYMK + case PHOTOMETRIC_SEPARATED: // CMYK { switch( this->_info._bits_per_sample ) { diff --git a/include/boost/gil/extension/io/tiff/detail/scanline_read.hpp b/include/boost/gil/extension/io/tiff/detail/scanline_read.hpp index f3369c4714..6e4cb946e0 100644 --- a/include/boost/gil/extension/io/tiff/detail/scanline_read.hpp +++ b/include/boost/gil/extension/io/tiff/detail/scanline_read.hpp @@ -326,7 +326,7 @@ class scanline_reader< Device break; } - case PHOTOMETRIC_SEPARATED: // CYMK + case PHOTOMETRIC_SEPARATED: // CMYK { switch( this->_info._bits_per_sample ) { diff --git a/include/boost/gil/image_processing/convolve.hpp b/include/boost/gil/image_processing/convolve.hpp index 39a852e565..bda11f4a73 100644 --- a/include/boost/gil/image_processing/convolve.hpp +++ b/include/boost/gil/image_processing/convolve.hpp @@ -27,7 +27,7 @@ namespace boost { namespace gil { -// 2D spatial seperable convolutions and cross-correlations +// 2D spatial separable convolutions and cross-correlations namespace detail { diff --git a/include/boost/gil/image_processing/histogram_matching.hpp b/include/boost/gil/image_processing/histogram_matching.hpp index 1b947c426f..765188c344 100644 --- a/include/boost/gil/image_processing/histogram_matching.hpp +++ b/include/boost/gil/image_processing/histogram_matching.hpp @@ -30,7 +30,7 @@ namespace boost { namespace gil { /// Algorithm :- /// 1. Calculate histogram A(pixel) of input image and G(pixel) of reference image. /// 2. Compute the normalized cumulative(CDF) histograms of A and G. -/// 3. Match the histograms using transofrmation => CDF(A(px)) = CDF(G(px')) +/// 3. Match the histograms using transformation => CDF(A(px)) = CDF(G(px')) /// => px' = Inv-CDF (CDF(px)) /// @@ -73,7 +73,7 @@ auto histogram_matching( std::is_integral::value && std::is_integral::value && std::is_integral::value, - "Source, Refernce or Destination histogram type is not appropriate."); + "Source, Reference or Destination histogram type is not appropriate."); using value_t = typename histogram::value_type; dst_hist.clear(); diff --git a/include/boost/gil/image_processing/threshold.hpp b/include/boost/gil/image_processing/threshold.hpp index b3b56356fc..6dceaf976a 100644 --- a/include/boost/gil/image_processing/threshold.hpp +++ b/include/boost/gil/image_processing/threshold.hpp @@ -161,7 +161,7 @@ void threshold_binary( /// \ingroup ImageProcessing /// \brief Applies truncating threshold to each pixel of image view. -/// Takes an image view and performs truncating threshold operation on each chennel. +/// Takes an image view and performs truncating threshold operation on each channel. /// If mode is threshold and direction is regular: /// values greater than threshold_value will be set to threshold_value else no change /// If mode is threshold and direction is inverse: diff --git a/test/extension/io/tiff/tiff_file_format_test.cpp b/test/extension/io/tiff/tiff_file_format_test.cpp index 4264312f74..3040ba5f82 100644 --- a/test/extension/io/tiff/tiff_file_format_test.cpp +++ b/test/extension/io/tiff/tiff_file_format_test.cpp @@ -346,8 +346,8 @@ void test_thirty_two_bit_contiguous_rgb_image() #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES } -// flower-rgb-planar-02.tif 73x43 2-bit seperated RGB image -void test_two_bit_seperated_rgb_image() +// flower-rgb-planar-02.tif 73x43 2-bit separated RGB image +void test_two_bit_separated_rgb_image() { std::string filename(tiff_in + "libtiffpic/depth/flower-rgb-planar-02.tif"); @@ -360,8 +360,8 @@ void test_two_bit_seperated_rgb_image() #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES } -// flower-rgb-planar-04.tif 73x43 4-bit seperated RGB image -void test_four_bit_seperated_rgb_image() +// flower-rgb-planar-04.tif 73x43 4-bit separated RGB image +void test_four_bit_separated_rgb_image() { std::string filename(tiff_in + "libtiffpic/depth/flower-rgb-planar-04.tif"); @@ -374,8 +374,8 @@ void test_four_bit_seperated_rgb_image() #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES } -// flower-rgb-planar-08.tif 73x43 8-bit seperated RGB image -void test_eight_bit_seperated_rgb_image() +// flower-rgb-planar-08.tif 73x43 8-bit separated RGB image +void test_eight_bit_separated_rgb_image() { std::string filename(tiff_in + "libtiffpic/depth/flower-rgb-planar-08.tif"); @@ -388,8 +388,8 @@ void test_eight_bit_seperated_rgb_image() #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES } -// flower-rgb-planar-10.tif 73x43 10-bit seperated RGB image -void test_ten_bit_seperated_rgb_image() +// flower-rgb-planar-10.tif 73x43 10-bit separated RGB image +void test_ten_bit_separated_rgb_image() { std::string filename(tiff_in + "libtiffpic/depth/flower-rgb-planar-10.tif"); @@ -402,8 +402,8 @@ void test_ten_bit_seperated_rgb_image() #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES } -// flower-rgb-planar-12.tif 73x43 12-bit seperated RGB image -void test_twelve_bit_seperated_rgb_image() +// flower-rgb-planar-12.tif 73x43 12-bit separated RGB image +void test_twelve_bit_separated_rgb_image() { std::string filename(tiff_in + "libtiffpic/depth/flower-rgb-planar-12.tif"); @@ -416,8 +416,8 @@ void test_twelve_bit_seperated_rgb_image() #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES } -// flower-rgb-planar-14.tif 73x43 14-bit seperated RGB image -void test_fourteen_bit_seperated_rgb_image() +// flower-rgb-planar-14.tif 73x43 14-bit separated RGB image +void test_fourteen_bit_separated_rgb_image() { std::string filename(tiff_in + "libtiffpic/depth/flower-rgb-planar-14.tif"); @@ -430,8 +430,8 @@ void test_fourteen_bit_seperated_rgb_image() #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES } -// flower-rgb-planar-16.tif 73x43 16-bit seperated RGB image -void test_sixteen_bit_seperated_rgb_image() +// flower-rgb-planar-16.tif 73x43 16-bit separated RGB image +void test_sixteen_bit_separated_rgb_image() { std::string filename(tiff_in + "libtiffpic/depth/flower-rgb-planar-16.tif"); @@ -444,8 +444,8 @@ void test_sixteen_bit_seperated_rgb_image() #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES } -// flower-rgb-planar-24.tif 73x43 24-bit seperated RGB image -void test_twenty_four_bit_seperated_rgb_image() +// flower-rgb-planar-24.tif 73x43 24-bit separated RGB image +void test_twenty_four_bit_separated_rgb_image() { std::string filename(tiff_in + "libtiffpic/depth/flower-rgb-planar-24.tif"); @@ -458,8 +458,8 @@ void test_twenty_four_bit_seperated_rgb_image() #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES } -// flower-rgb-planar-32.tif 73x43 32-bit seperated RGB image -void test_thirty_two_bit_seperated_rgb_image() +// flower-rgb-planar-32.tif 73x43 32-bit separated RGB image +void test_thirty_two_bit_separated_rgb_image() { std::string filename(tiff_in + "libtiffpic/depth/flower-rgb-planar-32.tif"); @@ -609,15 +609,15 @@ int main() test_sixteen_bit_contiguous_rgb_image(); test_twenty_four_bit_contiguous_rgb_image(); test_thirty_two_bit_contiguous_rgb_image(); - test_two_bit_seperated_rgb_image(); - test_four_bit_seperated_rgb_image(); - test_eight_bit_seperated_rgb_image(); - test_ten_bit_seperated_rgb_image(); - test_twelve_bit_seperated_rgb_image(); - test_fourteen_bit_seperated_rgb_image(); - test_sixteen_bit_seperated_rgb_image(); - test_twenty_four_bit_seperated_rgb_image(); - test_thirty_two_bit_seperated_rgb_image(); + test_two_bit_separated_rgb_image(); + test_four_bit_separated_rgb_image(); + test_eight_bit_separated_rgb_image(); + test_ten_bit_separated_rgb_image(); + test_twelve_bit_separated_rgb_image(); + test_fourteen_bit_separated_rgb_image(); + test_sixteen_bit_separated_rgb_image(); + test_twenty_four_bit_separated_rgb_image(); + test_thirty_two_bit_separated_rgb_image(); test_eight_bit_contiguous_cmyk_image(); test_sixteen_bit_contiguous_cmyk_image(); test_eight_bit_separated_cmyk_image(); From 91e2dcc9a4318d15833881b1d9d07c0abebba540 Mon Sep 17 00:00:00 2001 From: Dirk Stolle Date: Tue, 23 Jul 2024 15:57:13 +0200 Subject: [PATCH 2/3] ci: update codecov/codecov-action in GitHub Actions workflow to v4 (#755) --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 3e9b878dd9..5d262906a5 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -49,6 +49,6 @@ jobs: lcov --list coverage.info - name: Upload to Codecov - uses: codecov/codecov-action@v1.2.1 + uses: codecov/codecov-action@v4 with: files: ../boost-root/coverage.info From f56c4c65a8afc51df57e2e2653c5e35ed29a2423 Mon Sep 17 00:00:00 2001 From: Dirk Stolle Date: Tue, 23 Jul 2024 15:58:12 +0200 Subject: [PATCH 3/3] tests: add test cases for wide character path conversions (#754) --- test/core/CMakeLists.txt | 1 + test/core/Jamfile | 1 + test/core/io/CMakeLists.txt | 25 ++++++++++++++++ test/core/io/Jamfile | 13 ++++++++ test/core/io/path_spec.cpp | 59 +++++++++++++++++++++++++++++++++++++ 5 files changed, 99 insertions(+) create mode 100644 test/core/io/CMakeLists.txt create mode 100644 test/core/io/Jamfile create mode 100644 test/core/io/path_spec.cpp diff --git a/test/core/CMakeLists.txt b/test/core/CMakeLists.txt index 2b70482aa0..ee09332906 100644 --- a/test/core/CMakeLists.txt +++ b/test/core/CMakeLists.txt @@ -41,3 +41,4 @@ add_subdirectory(image_view) add_subdirectory(algorithm) add_subdirectory(image_processing) add_subdirectory(histogram) +add_subdirectory(io) diff --git a/test/core/Jamfile b/test/core/Jamfile index 9305b8762c..25156392e4 100644 --- a/test/core/Jamfile +++ b/test/core/Jamfile @@ -33,3 +33,4 @@ build-project image_view ; build-project algorithm ; build-project image_processing ; build-project histogram ; +build-project io ; diff --git a/test/core/io/CMakeLists.txt b/test/core/io/CMakeLists.txt new file mode 100644 index 0000000000..171e354854 --- /dev/null +++ b/test/core/io/CMakeLists.txt @@ -0,0 +1,25 @@ +# +# Copyright (c) 2024 Dirk Stolle +# +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) +# +foreach(_name + path_spec) + set(_test t_core_io_${_name}) + set(_target test_core_io_${_name}) + + add_executable(${_target} "") + target_sources(${_target} PRIVATE ${_name}.cpp) + target_link_libraries(${_target} + PRIVATE + gil_compile_options + gil_include_directories + gil_dependencies) + add_test(NAME ${_test} COMMAND ${_target}) + + unset(_name) + unset(_target) + unset(_test) +endforeach() diff --git a/test/core/io/Jamfile b/test/core/io/Jamfile new file mode 100644 index 0000000000..f696d70763 --- /dev/null +++ b/test/core/io/Jamfile @@ -0,0 +1,13 @@ +# Boost.GIL (Generic Image Library) - tests +# +# Copyright (c) 2024 Dirk Stolle +# +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or +# copy at http://www.boost.org/LICENSE_1_0.txt) + +import testing ; + +compile path_spec.cpp ; + +run path_spec.cpp ; diff --git a/test/core/io/path_spec.cpp b/test/core/io/path_spec.cpp new file mode 100644 index 0000000000..8179512e6a --- /dev/null +++ b/test/core/io/path_spec.cpp @@ -0,0 +1,59 @@ +// +// Copyright 2024 Dirk Stolle +// +// Distributed under the Boost Software License, Version 1.0 +// See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt + +#include +#include +#include +#include +#include + +namespace gil = boost::gil; + +void test_convert_to_string_from_wstring() +{ + std::wstring const path = L"/some_path/傳/привет/qwerty"; + std::string const expected = "/some_path/\xE5\x82\xB3/\xD0\xBF\xD1\x80\xD0\xB8\xD0\xB2\xD0\xB5\xD1\x82/qwerty"; + + std::string string = gil::detail::convert_to_string(path); + BOOST_TEST_EQ( 34, string.size() ); + BOOST_TEST_EQ( expected, string ); +} + +void test_convert_to_native_string_from_wchar_t_ptr() +{ + wchar_t const* path = L"/some_path/傳/привет/qwerty"; + char const* expected = "/some_path/\xE5\x82\xB3/\xD0\xBF\xD1\x80\xD0\xB8\xD0\xB2\xD0\xB5\xD1\x82/qwerty"; + + char const* string = gil::detail::convert_to_native_string(path); + BOOST_TEST_EQ( 34, strlen(string) ); + BOOST_TEST_EQ( 0, std::strcmp(expected, string) ); + delete[] string; +} + +void test_convert_to_native_string_from_wstring() +{ + std::wstring const path = L"/some_path/傳/привет/qwerty"; + char const* expected = "/some_path/\xE5\x82\xB3/\xD0\xBF\xD1\x80\xD0\xB8\xD0\xB2\xD0\xB5\xD1\x82/qwerty"; + + char const* string = gil::detail::convert_to_native_string(path); + BOOST_TEST_EQ( 34, strlen(string) ); + BOOST_TEST_EQ( 0, std::strcmp(expected, string) ); + delete[] string; +} + +int main() +{ + // Set global locale to one that uses UTF-8. Could be "en_US.UTF-8" or + // "C.UTF-8" or something similar, as long as it exists on the system. + std::locale::global(std::locale("C.UTF-8")); + + test_convert_to_string_from_wstring(); + test_convert_to_native_string_from_wchar_t_ptr(); + test_convert_to_native_string_from_wstring(); + + return boost::report_errors(); +}