diff --git a/source/simple/graphical/pixels.cpp b/source/simple/graphical/pixels.cpp index 265577927979270a26272565108750149ce4e124..bac00b7fed7aaf1441e5681d93e13e160102c4d6 100644 --- a/source/simple/graphical/pixels.cpp +++ b/source/simple/graphical/pixels.cpp @@ -37,6 +37,7 @@ SIMPLE_GRAPHICAL_PIXEL_WRITER_SET(rgba_pixel, rgb_vector, rgb_vector) SIMPLE_GRAPHICAL_PIXEL_WRITER_SET(rgba_pixel, rgba_vector, rgba_vector) SIMPLE_GRAPHICAL_PIXEL_WRITER_SET(rgba_pixel, rgb_vector, rgba_pixel) SIMPLE_GRAPHICAL_PIXEL_WRITER_SET(rgba_pixel, rgba_vector, rgba_pixel) +// SIMPLE_GRAPHICAL_PIXEL_WRITER_SET(uint16_t, float, uint16_t) // TODO #undef SIMPLE_GRAPHICAL_PIXEL_WRITER_SET using namespace pixel_view_details; #define SIMPLE_GRAPHICAL_PIXEL_VIEW_GET(Tag,Pixel,Vector) \ @@ -46,10 +47,14 @@ SIMPLE_GRAPHICAL_PIXEL_VIEW_GET(tag::reader, rgb_pixel, rgb_vector) SIMPLE_GRAPHICAL_PIXEL_VIEW_GET(tag::reader, rgb_pixel, rgba_vector) SIMPLE_GRAPHICAL_PIXEL_VIEW_GET(tag::reader, rgba_pixel, rgb_vector) SIMPLE_GRAPHICAL_PIXEL_VIEW_GET(tag::reader, rgba_pixel, rgba_vector) +SIMPLE_GRAPHICAL_PIXEL_VIEW_GET(tag::reader, uint16_t, float) +SIMPLE_GRAPHICAL_PIXEL_VIEW_GET(tag::reader, pixel_byte, float) SIMPLE_GRAPHICAL_PIXEL_VIEW_GET(tag::writer, rgb_pixel, rgb_vector) SIMPLE_GRAPHICAL_PIXEL_VIEW_GET(tag::writer, rgb_pixel, rgba_vector) SIMPLE_GRAPHICAL_PIXEL_VIEW_GET(tag::writer, rgba_pixel, rgb_vector) SIMPLE_GRAPHICAL_PIXEL_VIEW_GET(tag::writer, rgba_pixel, rgba_vector) +SIMPLE_GRAPHICAL_PIXEL_VIEW_GET(tag::writer, uint16_t, float) +SIMPLE_GRAPHICAL_PIXEL_VIEW_GET(tag::writer, pixel_byte, float) #undef SIMPLE_GRAPHICAL_PIXEL_VIEW_GET } // namespace simple::graphical diff --git a/source/simple/graphical/pixels.h b/source/simple/graphical/pixels.h index a932b7d8ed5531e096b32208c6ef643a6dfff438..b62093bc5a121b47c64cc64b4e954dd049ae177e 100644 --- a/source/simple/graphical/pixels.h +++ b/source/simple/graphical/pixels.h @@ -21,6 +21,21 @@ namespace simple::graphical namespace pixel_view_details { + template <typename Pixel> + struct pixel_fraction { using type = rgba_vector; }; + + template <> + struct pixel_fraction<rgba_pixel> { using type = rgba_vector; }; + template <> + struct pixel_fraction<rgb_pixel> { using type = rgb_vector; }; + template <> + struct pixel_fraction<uint16_t> { using type = float; }; + template <> + struct pixel_fraction<pixel_byte> { using type = float; }; + + template <typename Pixel> + using pixel_fraction_t = typename pixel_fraction<Pixel>::type; + class tag { public: @@ -73,10 +88,10 @@ namespace simple::graphical auto get(int2 position) const -> std::conditional_t<std::is_same_v<Pixel,RawType>, const Pixel&, Pixel>; - template <typename ColorVector = rgba_vector> + template <typename ColorVector = pixel_fraction_t<Pixel>> Pixel get(float2 position) const; - template <typename ColorVector = rgba_vector> + template <typename ColorVector = pixel_fraction_t<Pixel>> Pixel get(float2 position, range2D spread) const; impl(const impl & other, range2D range); diff --git a/source/simple/graphical/pixels.hpp b/source/simple/graphical/pixels.hpp index 23fc9be4523b9a6c460d4e3ff0551fe97e21b86e..813d93545ee465f4514544fdd32217a1343f59f6 100644 --- a/source/simple/graphical/pixels.hpp +++ b/source/simple/graphical/pixels.hpp @@ -116,7 +116,7 @@ namespace simple::graphical const float2 size(this->size()); assert(float2::one(-1) < position && position < size); - return get(position, + return get<ColorVector>(position, { int2(position < float2::zero()), int2::one(2) - int2(position > (size - 1)) @@ -217,7 +217,7 @@ namespace simple::graphical const float2 size(this->size()); assert(float2::one(-1) < position && position < size); - set(pixel, position, + set<ColorVector>(pixel, position, { int2(position < float2::zero()), int2::one(2) - int2(position > (size - 1))