Skip to content
Snippets Groups Projects
Commit 22ab3197 authored by namark's avatar namark
Browse files

Floating get for 1 and 2 byte pixel view.

parent 94909175
No related branches found
No related tags found
No related merge requests found
...@@ -37,6 +37,7 @@ SIMPLE_GRAPHICAL_PIXEL_WRITER_SET(rgba_pixel, rgb_vector, rgb_vector) ...@@ -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, rgba_vector, rgba_vector)
SIMPLE_GRAPHICAL_PIXEL_WRITER_SET(rgba_pixel, rgb_vector, rgba_pixel) 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(rgba_pixel, rgba_vector, rgba_pixel)
// SIMPLE_GRAPHICAL_PIXEL_WRITER_SET(uint16_t, float, uint16_t) // TODO
#undef SIMPLE_GRAPHICAL_PIXEL_WRITER_SET #undef SIMPLE_GRAPHICAL_PIXEL_WRITER_SET
using namespace pixel_view_details; using namespace pixel_view_details;
#define SIMPLE_GRAPHICAL_PIXEL_VIEW_GET(Tag,Pixel,Vector) \ #define SIMPLE_GRAPHICAL_PIXEL_VIEW_GET(Tag,Pixel,Vector) \
...@@ -46,10 +47,14 @@ SIMPLE_GRAPHICAL_PIXEL_VIEW_GET(tag::reader, rgb_pixel, rgb_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, rgb_pixel, rgba_vector)
SIMPLE_GRAPHICAL_PIXEL_VIEW_GET(tag::reader, rgba_pixel, rgb_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, 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, rgb_vector)
SIMPLE_GRAPHICAL_PIXEL_VIEW_GET(tag::writer, rgb_pixel, rgba_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, rgb_vector)
SIMPLE_GRAPHICAL_PIXEL_VIEW_GET(tag::writer, rgba_pixel, rgba_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 #undef SIMPLE_GRAPHICAL_PIXEL_VIEW_GET
} // namespace simple::graphical } // namespace simple::graphical
...@@ -21,6 +21,21 @@ namespace simple::graphical ...@@ -21,6 +21,21 @@ namespace simple::graphical
namespace pixel_view_details 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 class tag
{ {
public: public:
...@@ -73,10 +88,10 @@ namespace simple::graphical ...@@ -73,10 +88,10 @@ namespace simple::graphical
auto get(int2 position) const auto get(int2 position) const
-> std::conditional_t<std::is_same_v<Pixel,RawType>, const Pixel&, Pixel>; -> 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; Pixel get(float2 position) const;
template <typename ColorVector = rgba_vector> template <typename ColorVector = pixel_fraction_t<Pixel>>
Pixel get(float2 position, range2D spread) const; Pixel get(float2 position, range2D spread) const;
impl(const impl & other, range2D range); impl(const impl & other, range2D range);
......
...@@ -116,7 +116,7 @@ namespace simple::graphical ...@@ -116,7 +116,7 @@ namespace simple::graphical
const float2 size(this->size()); const float2 size(this->size());
assert(float2::one(-1) < position && position < size); assert(float2::one(-1) < position && position < size);
return get(position, return get<ColorVector>(position,
{ {
int2(position < float2::zero()), int2(position < float2::zero()),
int2::one(2) - int2(position > (size - 1)) int2::one(2) - int2(position > (size - 1))
...@@ -217,7 +217,7 @@ namespace simple::graphical ...@@ -217,7 +217,7 @@ namespace simple::graphical
const float2 size(this->size()); const float2 size(this->size());
assert(float2::one(-1) < position && position < size); assert(float2::one(-1) < position && position < size);
set(pixel, position, set<ColorVector>(pixel, position,
{ {
int2(position < float2::zero()), int2(position < float2::zero()),
int2::one(2) - int2(position > (size - 1)) int2::one(2) - int2(position > (size - 1))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment