Compare commits
No commits in common. "d9edd85e605bdc1e397d65930b10c2b0338dc967" and "cd9eafca84108c9eb4c42ef16e80dfe7422baf67" have entirely different histories.
d9edd85e60
...
cd9eafca84
2 changed files with 11 additions and 59 deletions
|
@ -70,8 +70,8 @@ struct matrix final {
|
||||||
template <size_type idx> auto get(this auto&& self) -> decltype(auto) {
|
template <size_type idx> auto get(this auto&& self) -> decltype(auto) {
|
||||||
static_assert(idx < Rows, "Out of bounds access to a member.");
|
static_assert(idx < Rows, "Out of bounds access to a member.");
|
||||||
// TODO: use forward_like when clang is catching up
|
// TODO: use forward_like when clang is catching up
|
||||||
return std::forward_like<decltype(self)>(self.m_[idx]);
|
// return std::forward_like<decltype(self)>(self.m_[idx]);
|
||||||
// return std::forward<decltype(self)>(self).m_[idx];
|
return std::forward<decltype(self)>(self).m_[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr auto diagonal() const noexcept -> diag_type {
|
constexpr auto diagonal() const noexcept -> diag_type {
|
||||||
|
|
|
@ -11,28 +11,14 @@ namespace pw {
|
||||||
|
|
||||||
struct image_layout {
|
struct image_layout {
|
||||||
|
|
||||||
enum struct pixel_layout { RGB8, RGBA8, LUM8, DEPTH };
|
enum pixel_layout { RGB8, RGBA8, LUM8, DEPTH };
|
||||||
|
|
||||||
static constexpr auto bits_per_channel(pixel_layout layout) {
|
static constexpr auto bits_per_channel(pixel_layout layout) {
|
||||||
constexpr static auto lut = std::array{
|
|
||||||
std::make_tuple(pixel_layout::RGB8, sizeof(std::uint8_t) << 3),
|
|
||||||
std::make_tuple(pixel_layout::RGBA8, sizeof(std::uint8_t) << 3),
|
|
||||||
std::make_tuple(pixel_layout::LUM8, sizeof(std::uint8_t) << 3),
|
|
||||||
std::make_tuple(pixel_layout::DEPTH, sizeof(float) << 3)};
|
|
||||||
|
|
||||||
const auto iter = std::find_if(
|
|
||||||
std::begin(lut), std::end(lut),
|
|
||||||
[&layout](const auto& v) { return std::get<0>(v) == layout; });
|
|
||||||
|
|
||||||
return iter != std::end(lut) ? std::get<1>(*iter) : 0u;
|
|
||||||
}
|
|
||||||
|
|
||||||
static constexpr auto channels(pixel_layout layout) {
|
|
||||||
constexpr static auto lut =
|
constexpr static auto lut =
|
||||||
std::array{std::make_tuple(pixel_layout::RGB8, 3),
|
std::array{std::make_tuple(RGB8, sizeof(std::uint8_t) << 3),
|
||||||
std::make_tuple(pixel_layout::RGBA8, 4),
|
std::make_tuple(RGBA8, sizeof(std::uint8_t) << 3),
|
||||||
std::make_tuple(pixel_layout::LUM8, 1),
|
std::make_tuple(LUM8, sizeof(std::uint8_t) << 3),
|
||||||
std::make_tuple(pixel_layout::DEPTH, 1)};
|
std::make_tuple(DEPTH, sizeof(float) << 3)};
|
||||||
|
|
||||||
const auto iter = std::find_if(
|
const auto iter = std::find_if(
|
||||||
std::begin(lut), std::end(lut),
|
std::begin(lut), std::end(lut),
|
||||||
|
@ -40,39 +26,16 @@ struct image_layout {
|
||||||
|
|
||||||
return iter != std::end(lut) ? std::get<1>(*iter) : 0u;
|
return iter != std::end(lut) ? std::get<1>(*iter) : 0u;
|
||||||
}
|
}
|
||||||
|
|
||||||
size<int32_t> size_{};
|
|
||||||
pixel_layout layout_{pixel_layout::RGB8};
|
|
||||||
};
|
|
||||||
|
|
||||||
struct image_new {
|
|
||||||
|
|
||||||
using buffer_type = std::vector<uint8_t>;
|
|
||||||
using size_type = pw::size<int32_t>;
|
|
||||||
|
|
||||||
image_layout layout;
|
|
||||||
buffer_type buffer{};
|
|
||||||
|
|
||||||
static constexpr auto make(const image_new::size_type& size_,
|
|
||||||
image_layout::pixel_layout layout_)
|
|
||||||
-> image_new {
|
|
||||||
|
|
||||||
return {.layout{.layout_ = layout_},
|
|
||||||
.buffer{buffer_type{
|
|
||||||
static_cast<buffer_type::value_type>(
|
|
||||||
(image_layout::bits_per_channel(layout_) >> 3) *
|
|
||||||
size_.area() * image_layout::channels(layout_)),
|
|
||||||
buffer_type::value_type{0}}}};
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace pw
|
} // namespace pw
|
||||||
|
|
||||||
auto main() -> int {
|
auto main() -> int {
|
||||||
|
|
||||||
std::print("RGB8 = {}bits per channel\n",
|
auto val = pw::image_layout::bits_per_channel(
|
||||||
pw::image_layout::bits_per_channel(
|
pw::image_layout::pixel_layout::RGB8);
|
||||||
pw::image_layout::pixel_layout::RGB8));
|
|
||||||
|
std::print("RGB8 = {}bits per channel\n", val);
|
||||||
std::print("DEPTH = {}bits per channel\n",
|
std::print("DEPTH = {}bits per channel\n",
|
||||||
pw::image_layout::bits_per_channel(
|
pw::image_layout::bits_per_channel(
|
||||||
pw::image_layout::pixel_layout::DEPTH));
|
pw::image_layout::pixel_layout::DEPTH));
|
||||||
|
@ -80,16 +43,5 @@ auto main() -> int {
|
||||||
pw::image_layout::bits_per_channel(
|
pw::image_layout::bits_per_channel(
|
||||||
pw::image_layout::pixel_layout::LUM8));
|
pw::image_layout::pixel_layout::LUM8));
|
||||||
|
|
||||||
std::print(
|
|
||||||
"RGB8 = {}channels\n",
|
|
||||||
pw::image_layout::channels(pw::image_layout::pixel_layout::RGB8));
|
|
||||||
std::print(
|
|
||||||
"DEPTH = {}channels\n",
|
|
||||||
pw::image_layout::channels(pw::image_layout::pixel_layout::DEPTH));
|
|
||||||
std::print(
|
|
||||||
"LUM8 = {}channels\n",
|
|
||||||
pw::image_layout::channels(pw::image_layout::pixel_layout::LUM8));
|
|
||||||
// pw::image
|
// pw::image
|
||||||
|
|
||||||
pw::image_new::make(pw::iamge, image_layout::pixel_layout layout_)
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue