File: targa_old_test.cpp

package info (click to toggle)
boost1.74 1.74.0-9
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 464,084 kB
  • sloc: cpp: 3,338,324; xml: 131,293; python: 33,088; ansic: 14,336; asm: 4,034; sh: 3,351; makefile: 1,193; perl: 1,036; yacc: 478; php: 212; ruby: 102; lisp: 24; sql: 13; csh: 6
file content (92 lines) | stat: -rw-r--r-- 2,141 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//
// 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
//
#include <boost/gil.hpp>
#include <boost/gil/extension/io/targa/old.hpp>

#include <boost/core/lightweight_test.hpp>
#include <boost/mp11.hpp>

#include "mandel_view.hpp"
#include "paths.hpp"

namespace gil  = boost::gil;
namespace mp11 = boost::mp11;

void test_old_read_dimensions()
{
    boost::gil::point_t dim = gil::targa_read_dimensions(targa_filename);

    BOOST_TEST_EQ(dim.x, 124);
    BOOST_TEST_EQ(dim.y, 124);
}

void test_old_read_image()
{
    gil::rgb8_image_t img;
    gil::targa_read_image(targa_filename, img);

    BOOST_TEST_EQ(img.width(), 124);
    BOOST_TEST_EQ(img.height(), 124);
}

void test_old_read_and_convert_image()
{
    gil::rgb8_image_t img;
    gil::targa_read_and_convert_image(targa_filename, img);

    BOOST_TEST_EQ(img.width(), 124);
    BOOST_TEST_EQ(img.height(), 124);
}

void test_old_read_view()
{
    gil::rgb8_image_t img(124, 124);
    gil::targa_read_view(targa_filename, gil::view(img));
}

void test_old_read_and_convert_view()
{
    gil::rgb8_image_t img(124, 124);
    gil::targa_read_and_convert_view(targa_filename, gil::view(img));
}

void test_old_write_view()
{
    targa_write_view(
        targa_out + "old_write_view_test.tga",
        create_mandel_view(124, 124, gil::rgb8_pixel_t(0, 0, 255), gil::rgb8_pixel_t(0, 255, 0)));
}

void test_old_dynamic_image()
{
    using my_img_types = mp11::mp_list
    <
        gil::gray8_image_t,
        gil::gray16_image_t,
        gil::rgb8_image_t,
        gil::rgba8_image_t
    >;

    gil::any_image<my_img_types> image;
    gil::targa_read_image(targa_filename.c_str(), image);

    targa_write_view(targa_out + "old_dynamic_image_test.tga", gil::view(image));
}

int main()
{
    test_old_read_dimensions();
    test_old_read_image();
    test_old_read_and_convert_image();
    test_old_read_view();
    test_old_read_and_convert_view();
    test_old_write_view();
    test_old_dynamic_image();

    return boost::report_errors();
}