diff options
author | Keuin <[email protected]> | 2022-04-14 12:54:06 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2022-04-14 12:58:28 +0800 |
commit | a41fbf75aff54f4d3bd88793cdf2bf281ea9ee01 (patch) | |
tree | f6f65379568a80c2c22692d1914215c582a9b338 /test_bitmap.cpp | |
parent | e46e1c4033b9d96325de3295eb442a5b1fa19f19 (diff) |
Add pixel and bitmap color depth conversion.
Diffstat (limited to 'test_bitmap.cpp')
-rw-r--r-- | test_bitmap.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test_bitmap.cpp b/test_bitmap.cpp new file mode 100644 index 0000000..4f20d3f --- /dev/null +++ b/test_bitmap.cpp @@ -0,0 +1,33 @@ +// +// Created by Keuin on 2022/4/14. +// + +#include <gtest/gtest.h> + +#include "bitmap.h" + +TEST(Pixel, PixelDepthConvert) { + const auto white8 = pixel8b::white(); + const auto white32 = pixel<uint32_t>::white(); + ASSERT_EQ(white8, pixel8b::from(white32)); + + const auto black8 = pixel8b::black(); + const auto black32 = pixel<uint32_t>::black(); + ASSERT_EQ(black8, pixel8b::from(black32)); + + const auto gray8 = pixel8b{127, 127, 127}; + const auto gray32 = pixel<uint32_t>{ + ((1ULL << 32U) - 1U) >> 1U, + ((1ULL << 32U) - 1U) >> 1U, + ((1ULL << 32U) - 1U) >> 1U + }; + ASSERT_EQ(gray8, pixel8b::from(gray32)); + + const auto mix8 = pixel8b{0, 127, 255}; + const auto mix32 = pixel<uint32_t>{ + 0, + ((1ULL << 32U) - 1U) >> 1U, + ((1ULL << 32U) - 1U) + }; + ASSERT_EQ(mix8, pixel8b::from(mix32)); +}
\ No newline at end of file |