2
0
mirror of https://github.com/boostorg/gil.git synced 2026-02-25 04:22:09 +00:00
Files
gil/toolbox/test/subchroma_image.cpp
Mateusz Loskot bf67e796c6 Apply clang-tidy modernize-use-using to all tests (#199)
Run clang-tidy 7.0 with `-checks='-*,modernize-use-using' -fix`
against TU-s of all tests.

Manually refactor numerous typedef-s
- where missed by modernize-use-using check, not uncommon
- in code snippets in comments

Outcome is that searching for lower-case whole word typedef
in sources of all the tests should return no matches.
2018-12-18 00:13:39 +01:00

100 lines
3.4 KiB
C++

// Copyright 2013 Christian Henning
// 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)
/// \brief Unit test for subchroma_image type.
#include <boost/test/unit_test.hpp>
#include <boost/gil.hpp>
#include <boost/gil/extension/toolbox/color_spaces/ycbcr.hpp>
#include <boost/gil/extension/toolbox/image_types/subchroma_image.hpp>
using namespace std;
using namespace boost;
using namespace gil;
BOOST_AUTO_TEST_SUITE( toolbox_tests )
BOOST_AUTO_TEST_CASE( subchroma_image_test )
{
{
ycbcr_601_8_pixel_t a( 10, 20, 30 );
rgb8_pixel_t b;
bgr8_pixel_t c;
color_convert( a, b );
color_convert( a, c );
BOOST_ASSERT( static_equal( b, c ));
color_convert( b, a );
}
{
ycbcr_709_8_pixel_t a( 10, 20, 30 );
rgb8_pixel_t b;
bgr8_pixel_t c;
color_convert( a, b );
color_convert( a, c );
BOOST_ASSERT( static_equal( b, c ));
color_convert( b, a );
}
{
using pixel_t = rgb8_pixel_t;
using image_t = subchroma_image<pixel_t>;
image_t img( 640, 480 );
fill_pixels( view( img )
, pixel_t( 10, 20, 30 )
);
}
{
using pixel_t = rgb8_pixel_t;
subchroma_image< pixel_t, mpl::vector_c< int, 4, 4, 4 > > a( 640, 480 ); BOOST_STATIC_ASSERT(( a.ss_X == 1 && a.ss_Y == 1 ));
subchroma_image< pixel_t, mpl::vector_c< int, 4, 4, 0 > > b( 640, 480 ); BOOST_STATIC_ASSERT(( b.ss_X == 1 && b.ss_Y == 2 ));
subchroma_image< pixel_t, mpl::vector_c< int, 4, 2, 2 > > c( 640, 480 ); BOOST_STATIC_ASSERT(( c.ss_X == 2 && c.ss_Y == 1 ));
subchroma_image< pixel_t, mpl::vector_c< int, 4, 2, 0 > > d( 640, 480 ); BOOST_STATIC_ASSERT(( d.ss_X == 2 && d.ss_Y == 2 ));
subchroma_image< pixel_t, mpl::vector_c< int, 4, 1, 1 > > e( 640, 480 ); BOOST_STATIC_ASSERT(( e.ss_X == 4 && e.ss_Y == 1 ));
subchroma_image< pixel_t, mpl::vector_c< int, 4, 1, 0 > > f( 640, 480 ); BOOST_STATIC_ASSERT(( f.ss_X == 4 && f.ss_Y == 2 ));
fill_pixels( view( a ), pixel_t( 10, 20, 30 ) );
fill_pixels( view( b ), pixel_t( 10, 20, 30 ) );
fill_pixels( view( c ), pixel_t( 10, 20, 30 ) );
fill_pixels( view( d ), pixel_t( 10, 20, 30 ) );
fill_pixels( view( e ), pixel_t( 10, 20, 30 ) );
fill_pixels( view( f ), pixel_t( 10, 20, 30 ) );
}
{
using pixel_t = ycbcr_601_8_pixel_t;
using factors_t = mpl::vector_c<int, 4, 2, 2>;
using image_t = subchroma_image<pixel_t, factors_t>;
std::size_t y_width = 640;
std::size_t y_height = 480;
std::size_t image_size = ( y_width * y_height )
+ ( y_width / image_t::ss_X ) * ( y_height / image_t::ss_Y )
+ ( y_width / image_t::ss_X ) * ( y_height / image_t::ss_Y );
vector< unsigned char > data( image_size );
image_t::view_t v = subchroma_view< pixel_t, factors_t >( y_width
, y_height
, &data.front()
);
rgb8_pixel_t p;
p = *v.xy_at( 0, 0 );
}
}
BOOST_AUTO_TEST_SUITE_END()