27 #ifndef MLN_VALUE_QT_RGB32_HH
28 # define MLN_VALUE_QT_RGB32_HH
35 # include <mln/value/ops.hh>
37 # include <mln/value/concept/vectorial.hh>
38 # include <mln/algebra/vec.hh>
40 # include <mln/literal/zero.hh>
41 # include <mln/literal/black.hh>
42 # include <mln/literal/white.hh>
43 # include <mln/literal/grays.hh>
44 # include <mln/literal/colors.hh>
51 # ifdef MLN_INCLUDE_ONLY
52 # include <mln/value/int_u.hh>
54 # define MLN_INCLUDE_ONLY
55 # include <mln/value/int_u.hh>
56 # undef MLN_INCLUDE_ONLY
64 namespace value {
namespace qt {
struct rgb32; } }
109 template <
typename S >
115 template <
typename S >
128 template <
unsigned m >
134 template <
unsigned m >
142 struct value_< mln::value::qt::rgb32 >
147 card = mln_value_card_from_(nbits)
150 typedef trait::value::nature::vectorial
nature;
151 typedef trait::value::kind::color
kind;
152 typedef trait::value::quant::high
quant;
159 template <
typename V>
static comp_0 get_comp_0(
const V& v) {
return v.red(); }
160 template <
typename V>
static comp_1 get_comp_1(
const V& v) {
return v.green(); }
161 template <
typename V>
static comp_2 get_comp_2(
const V& v) {
return v.blue(); }
163 typedef algebra::vec<dim, float>
sum;
165 static const char* name()
167 static std::string s =
"qt_rgb32";
197 algebra::vec< 3, int_u<8> >,
198 algebra::vec< 3, int >,
225 rgb32(
int r,
int g,
int b);
329 template <
typename S>
334 template <
typename S>
342 template <
typename S>
361 # ifndef MLN_INCLUDE_ONLY
372 # ifndef MLN_WO_GLOBAL_VARS
376 # endif // !MLN_WO_GLOBAL_VARS
429 mln_precondition(r >= 0);
430 mln_precondition(g >= 0);
431 mln_precondition(b >= 0);
432 mln_precondition(
unsigned(r) <= mln_max(int_u<8>));
433 mln_precondition(
unsigned(g) <= mln_max(int_u<8>));
434 mln_precondition(
unsigned(b) <= mln_max(int_u<8>));
453 this->
v_[0] = mln_max(int_u<8>);
454 this->
v_[1] = mln_max(int_u<8>);
455 this->
v_[2] = mln_max(int_u<8>);
471 this->
v_[0] =
unsigned(mln_max(int_u<8>)) * 3 / 4;
472 this->
v_[1] =
unsigned(mln_max(int_u<8>)) * 3 / 4;
473 this->
v_[2] =
unsigned(mln_max(int_u<8>)) * 3 / 4;
480 this->
v_[0] =
unsigned(mln_max(int_u<8>)) / 2;
481 this->
v_[1] =
unsigned(mln_max(int_u<8>)) / 2;
482 this->
v_[2] =
unsigned(mln_max(int_u<8>)) / 2;
489 this->
v_[0] =
unsigned(mln_max(int_u<8>)) / 4;
490 this->
v_[1] =
unsigned(mln_max(int_u<8>)) / 4;
491 this->
v_[2] =
unsigned(mln_max(int_u<8>)) / 4;
500 this->
v_[2] = mln_max(int_u<8>);
508 this->
v_[1] = mln_max(int_u<8>);
516 this->
v_[0] = mln_max(int_u<8>);
525 this->
v_[0] =
unsigned(mln_max(int_u<8>)) / 4;
526 this->
v_[1] =
unsigned(mln_max(int_u<8>)) / 2;
527 this->
v_[2] =
unsigned(mln_max(int_u<8>)) * 3 / 4;
535 this->
v_[1] = mln_max(int_u<8>);
536 this->
v_[2] =
unsigned(mln_max(int_u<8>)) * 3 / 4;
544 this->
v_[1] =
unsigned(mln_max(int_u<8>)) / 2;
545 this->
v_[2] = mln_max(int_u<8>);
552 this->
v_[0] =
unsigned(mln_max(int_u<8>)) * 3 / 4;
553 this->
v_[1] =
unsigned(mln_max(int_u<8>)) * 3 / 4;
554 this->
v_[2] = mln_max(int_u<8>);
561 this->
v_[0] =
unsigned(mln_max(int_u<8>)) / 4;
563 this->
v_[2] =
unsigned(mln_max(int_u<8>)) * 3 / 4;
570 this->
v_[0] =
unsigned(mln_max(int_u<8>)) / 2;
571 this->
v_[1] =
unsigned(mln_max(int_u<8>)) / 2;
579 this->
v_[0] =
unsigned(mln_max(int_u<8>)) / 2;
581 this->
v_[2] =
unsigned(mln_max(int_u<8>)) / 2;
588 this->
v_[0] = mln_max(int_u<8>);
589 this->
v_[1] = mln_max(int_u<8>);
597 this->
v_[0] = mln_max(int_u<8>);
599 this->
v_[2] = mln_max(int_u<8>);
607 this->
v_[1] = mln_max(int_u<8>);
608 this->
v_[2] = mln_max(int_u<8>);
616 this->
v_[1] =
unsigned(mln_max(int_u<8>)) / 2;
617 this->
v_[2] =
unsigned(mln_max(int_u<8>)) / 2;
633 rgb32::operator algebra::vec<3, int>()
const
635 algebra::vec<3, int> out;
636 out[0] = this->v_[2];
637 out[1] = this->v_[1];
638 out[2] = this->v_[0];
643 rgb32::operator algebra::vec<3, float>()
const
645 algebra::vec<3, float> out;
646 out[0] = this->v_[2];
647 out[1] = this->v_[1];
648 out[2] = this->v_[0];
660 operator+(
const rgb32& lhs,
const rgb32& rhs)
687 operator-(
const rgb32& lhs,
const rgb32& rhs)
711 template <
typename S>
720 template <
typename S>
729 template <
typename S>
740 std::ostream&
operator<<(std::ostream& ostr,
const rgb32& v)
750 std::istream&
operator>>(std::istream& istr, rgb32& c)
752 return istr >> c.red() >> c.green() >> c.blue();
759 void from_to_(
const rgb32& from,
bool& to)
765 void from_to_(
const bool& from, value::qt::rgb32& to)
779 # endif // ! MLN_INCLUDE_ONLY
783 # ifndef MLN_INCLUDE_ONLY
784 # include <mln/value/int_u.hxx>
785 # endif // ! MLN_INCLUDE_ONLY
788 #endif // ! MLN_VALUE_QT_RGB32_HH