Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using type = pixel<ChannelTraits...>;
- // the type used for doing intermediary conversions to different formats when no explicit conversion is implemented
- using rgb_conversion_type = pixel<channel_traits<channel_name::R,16>,channel_traits<channel_name::G,16>,channel_traits<channel_name::B,16>,channel_traits<channel_name::A,16>>;
- // the integer type of the pixel
- using int_type = bits::uintx<bits::get_word_size(helpers::bit_depth<ChannelTraits...>::value)>;
- // the number of channels
- constexpr static const size_t channels = sizeof...(ChannelTraits);
- // the total bit depth of the pixel
- constexpr static const size_t bit_depth = helpers::bit_depth<ChannelTraits...>::value;
- // the minimum number of bytes needed to store the pixel
- constexpr static const size_t packed_size = (bit_depth+7) / 8;
- // true if the pixel is a whole number of bytes
- constexpr static const bool byte_aligned = 0==bit_depth/8.0 - (size_t)(bit_depth/8);
- // the total size in bits, including padding
- constexpr static const size_t total_size_bits = sizeof(int_type)*8;
- // the packed size, in bits
- constexpr static const size_t packed_size_bits = packed_size*8;
- // the count of bits to the right that are unused
- constexpr static const size_t pad_right_bits = total_size_bits-bit_depth;
- // the mask of the pixel's value
- constexpr static const int_type mask = int_type(int_type(~int_type(0))<<(pad_right_bits));
- // the pixel value, in platform native format
- int_type native_value;
- ...
- // retrieves a channel's metadata by index
- template<int Index> using channel_by_index = typename helpers::channel_by_index_impl<type,Index,channels,0,ChannelTraits...>::type;
- // retrieves a channel's metadata by index in cases where the checked version will cause an error
- template<int Index> using channel_by_index_unchecked = typename helpers::channel_by_index_unchecked_impl<type,Index,channels,0,ChannelTraits...>::type;
- // gets the index of the channel by the channel name
- template<typename Name> using channel_index_by_name = typename helpers::channel_index_by_name_impl<0,Name,ChannelTraits...>;
- // gets the channel by name
- template<typename Name> using channel_by_name = channel_by_index<helpers::channel_index_by_name_impl<0,Name,ChannelTraits...>::value>;
- // retrieves a channel's metadata by name in cases where the checked version will cause an error
- template<typename Name> using channel_by_name_unchecked = channel_by_index_unchecked<channel_index_by_name<Name>::value>;
- // returns true if the pixel contains channels with each name
- template<typename... ChannelNames> using has_channel_names = typename helpers::has_channel_names_impl<type,ChannelNames...>;
- // returns true if this channel is a subset of the other
- template<typename PixelRhs> using is_subset_of = typename helpers::is_subset_pixel_impl<PixelRhs,ChannelTraits...>;
- // returns true if this channel is a superset of the other
- template<typename PixelRhs> using is_superset_of = typename PixelRhs::template is_subset_of<type>;
- // returns true if the two pixels have channels with the same names, regardless of order
- template<typename PixelRhs> using unordered_equals = typename helpers::unordered_equals_pixel_impl<type,PixelRhs>;
- // returns true if the two pixels have channels with the same names, in the same order
- template<typename PixelRhs> using equals = typename helpers::equals_pixel_impl<PixelRhs,ChannelTraits...>;
- // returns true if the two pixels are exactly the same
- template<typename PixelRhs> using equals_exact = typename helpers::is_same<type,PixelRhs>;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement