Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix error: RView identifier not found in planar_rgba_view (#332)
Add basic run-time test of `planar_rgba_view` function. Add missing includes of `pixel.hpp` and `planar_pixel_reference.hpp` also required for successful compilation. Fixes #331
- Loading branch information
Showing
5 changed files
with
55 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,4 @@ compile view_type.cpp ; | |
compile view_type_from_pixel.cpp ; | ||
|
||
run collection.cpp ; | ||
run planar_rgba_view.cpp ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// Copyright 2018 Mateusz Loskot <mateusz at loskot dot net> | ||
// | ||
// 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/core/lightweight_test.hpp> | ||
|
||
#include <cstdint> | ||
|
||
namespace gil = boost::gil; | ||
|
||
int main() | ||
{ | ||
gil::point_t d{2, 2}; | ||
std::uint8_t r[] = { 1, 2, 3, 4 }; | ||
std::uint8_t g[] = { 10, 20, 30, 40 }; | ||
std::uint8_t b[] = { 110, 120, 130, 140 }; | ||
std::uint8_t a[] = { 251, 252, 253, 254 }; | ||
|
||
auto v = gil::planar_rgba_view(d.x, d.y, r, g, b, a, sizeof(std::uint8_t) * 2); | ||
BOOST_TEST(!v.empty()); | ||
BOOST_TEST(v.dimensions() == d); | ||
BOOST_TEST(v.num_channels() == 4u); | ||
BOOST_TEST(v.size() == static_cast<std::size_t>(d.x * d.y)); | ||
|
||
gil::rgba8_pixel_t const pf{1, 10, 110, 251}; | ||
BOOST_TEST(v.front() == pf); | ||
|
||
gil::rgba8_pixel_t const pb{4, 40, 140, 254}; | ||
BOOST_TEST(v.back() == pb); | ||
|
||
for (std::ptrdiff_t i = 0; i < v.size(); i++) | ||
{ | ||
gil::rgba8_pixel_t const p{r[i], g[i], b[i], a[i]}; | ||
BOOST_TEST(v[i] == p); | ||
} | ||
|
||
return boost::report_errors(); | ||
} |