Color table implementation

This commit is contained in:
Dan Paulat 2021-07-01 22:05:47 -05:00
parent 6c25ce4230
commit d734bc6a0a
12 changed files with 437 additions and 5 deletions

View file

@ -1,2 +1,8 @@
cmake_minimum_required(VERSION 3.11)
set_property(DIRECTORY
APPEND
PROPERTY CMAKE_CONFIGURE_DEPENDS
test.cmake)
include(test.cmake)

@ -1 +1 @@
Subproject commit 40f68fe08977e5168679ce0419834312a6369205
Subproject commit 4bc8b8283fcd9d3ed0bcb3099d36db269209b7df

View file

@ -0,0 +1,34 @@
#include <scwx/common/color_table.hpp>
#include <gtest/gtest.h>
namespace scwx
{
namespace common
{
TEST(color_table, reflectivity)
{
std::string filename(std::string(SCWX_TEST_DATA_DIR) +
"/colors/reflectivity.pal");
std::shared_ptr<ColorTable> ct = ColorTable::Load(filename);
EXPECT_EQ(ct->Color(5), boost::gil::rgba8_pixel_t(164, 164, 255, 255));
EXPECT_EQ(ct->Color(10), boost::gil::rgba8_pixel_t(164, 164, 255, 255));
EXPECT_EQ(ct->Color(20), boost::gil::rgba8_pixel_t(64, 128, 255, 255));
EXPECT_EQ(ct->Color(30), boost::gil::rgba8_pixel_t(0, 255, 0, 255));
EXPECT_EQ(ct->Color(32), boost::gil::rgba8_pixel_t(0, 230, 0, 255));
EXPECT_EQ(ct->Color(35), boost::gil::rgba8_pixel_t(0, 192, 0, 255));
EXPECT_EQ(ct->Color(40), boost::gil::rgba8_pixel_t(255, 255, 0, 255));
EXPECT_EQ(ct->Color(50), boost::gil::rgba8_pixel_t(255, 0, 0, 255));
EXPECT_EQ(ct->Color(55), boost::gil::rgba8_pixel_t(208, 0, 0, 255));
EXPECT_EQ(ct->Color(60), boost::gil::rgba8_pixel_t(255, 0, 255, 255));
EXPECT_EQ(ct->Color(65), boost::gil::rgba8_pixel_t(192, 0, 192, 255));
EXPECT_EQ(ct->Color(70), boost::gil::rgba8_pixel_t(255, 255, 255, 255));
EXPECT_EQ(ct->Color(80), boost::gil::rgba8_pixel_t(128, 128, 128, 255));
EXPECT_EQ(ct->Color(85), boost::gil::rgba8_pixel_t(128, 128, 128, 255));
}
} // namespace common
} // namespace scwx

View file

@ -8,15 +8,18 @@ find_package(BZip2)
find_package(GTest)
set(SRC_MAIN source/scwx/wxtest.cpp)
set(SRC_COMMON_TESTS source/scwx/common/color_table.test.cpp)
set(SRC_UTIL_TESTS source/scwx/util/rangebuf.test.cpp
source/scwx/util/vectorbuf.test.cpp)
set(SRC_WSR88D_TESTS source/scwx/wsr88d/ar2v_file.test.cpp)
add_executable(wxtest ${SRC_MAIN}
${SRC_COMMON_TESTS}
${SRC_UTIL_TESTS}
${SRC_WSR88D_TESTS})
source_group("Source Files\\main" FILES ${SRC_MAIN})
source_group("Source Files\\common" FILES ${SRC_COMMON_TESTS})
source_group("Source Files\\util" FILES ${SRC_UTIL_TESTS})
source_group("Source Files\\wsr88d" FILES ${SRC_WSR88D_TESTS})
@ -38,6 +41,7 @@ target_link_libraries(wxtest Boost::iostreams
Boost::log
BZip2::BZip2
GTest::gtest
hsluv-c
wxdata)
if (WIN32)