8 #ifndef BOOST_GIL_IO_BIT_OPERATIONS_HPP 9 #define BOOST_GIL_IO_BIT_OPERATIONS_HPP 11 #include <boost/gil/io/typedefs.hpp> 15 #include <type_traits> 17 namespace boost {
namespace gil {
namespace detail {
20 template <
typename Buffer,
typename IsBitAligned>
25 void operator()(Buffer&) {}
26 void operator()(byte_t*, std::size_t){}
31 template <
typename Buffer>
32 struct mirror_bits<Buffer, std::true_type>
42 lookup_[i] = mirror(i);
48 void operator()(Buffer& buffer)
51 for_each(buffer.begin(), buffer.end(), [
this](byte_t& c) { lookup(c); });
54 void operator()(byte_t *dst, std::size_t size)
56 for (std::size_t i = 0; i < size; ++i)
65 void lookup(byte_t& c)
70 static byte_t mirror(byte_t c)
73 for (
int i = 0; i < 8; ++i)
83 std::array<byte_t, 256> lookup_;
84 bool apply_operation_;
89 template <
typename Buffer,
typename IsBitAligned>
92 void operator()(Buffer&) {};
95 template <
typename Buffer>
96 struct negate_bits<Buffer, std::true_type>
98 void operator()(Buffer& buffer)
100 for_each(buffer.begin(), buffer.end(),
101 negate_bits<Buffer, std::true_type>::negate);
104 void operator()(byte_t* dst, std::size_t size)
106 for (std::size_t i = 0; i < size; ++i)
115 static void negate(byte_t& b)
122 template <
typename Buffer,
typename IsBitAligned>
123 struct swap_half_bytes
125 void operator()(Buffer&) {};
128 template <
typename Buffer>
129 struct swap_half_bytes<Buffer, std::true_type>
131 void operator()(Buffer& buffer)
133 for_each(buffer.begin(), buffer.end(),
137 void operator()(byte_t* dst, std::size_t size)
139 for (std::size_t i = 0; i < size; ++i)
148 static void swap(byte_t& c)
150 c = ((c << 4) & 0xF0) | ((c >> 4) & 0x0F);
154 template <
typename Buffer>
157 do_nothing() =
default;
159 void operator()(Buffer&) {}
163 template <
typename T>
164 inline unsigned int trailing_zeros(T x) noexcept
179 template <
typename T>
181 unsigned int count_ones(T x) noexcept
BOOST_FORCEINLINE auto apply_operation(variant< Types > &arg, UnaryOp op)
Invokes a generic mutable operation (represented as a unary function object) on a variant.
Definition: apply_operation.hpp:21
void swap(boost::gil::packed_channel_reference< BF, FB, NB, M > const x, R &y)
swap for packed_channel_reference
Definition: channel.hpp:529