00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <mln/value/gl8.hh>
00027 #include <mln/value/gl16.hh>
00028 #include <mln/value/glf.hh>
00029
00030 #include <mln/value/int_u8.hh>
00031 #include <mln/value/int_s8.hh>
00032 #include <mln/value/float01_f.hh>
00033 #include <mln/value/float01_.hh>
00034
00035
00036 #include <mln/literal/black.hh>
00037 #include <mln/literal/white.hh>
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 #define test_conversion(T1, T2, VAL) \
00052 { \
00053 (T1)(T2)(VAL); \
00054 T1 test = (T2)(VAL); \
00055 test = (T2)(VAL); \
00056 }
00057
00058 int main()
00059 {
00060 using namespace mln::value;
00061 using namespace mln::value::internal;
00062
00063 using mln::literal::white;
00064 using mln::literal::black;
00065
00066
00067
00068
00069 gl8 a(white);
00070 gl8 b(white);
00071
00072 a = b;
00073 mln_assertion(a == b);
00074
00075 {
00076 gl8 a(10);
00077 gl8 b(10);
00078
00079 gl8 c = a + b;
00080 }
00081
00082 {
00083 gl8 a(white);
00084 gl8 b(white);
00085 gl8 c;
00086
00087
00088 a * 2;
00089 2 * a;
00090
00091
00092
00093 a * 2.0;
00094 2.0 * a;
00095
00096
00097 a * false;
00098 false * a;
00099
00100
00101 a * int_u8(23);
00102 int_u8(23) * a;
00103
00104
00105 a * float01_f(.23);
00106 float01_f(.23) * a;
00107
00108 float01_<16>(.23) * a;
00109 a * float01_<16>(.23);
00110
00111
00112
00113 a / 1.5;
00114
00115
00116 mln_assertion(a / 2.0 == glf(0.5));
00117
00118
00119 mln_assertion(a / true == a);
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130 a / int_u8(23);
00131 a / int_s8(23);
00132
00133
00134 a / float01_f(.23);
00135 a / float01_<16>(.23);
00136 }
00137
00138 {
00139
00140
00141 typedef mln::value::internal::gray_<8> i_gray_8;
00142 test_conversion(gl8, i_gray_8, 255);
00143
00144 test_conversion(gl8, gray_f, 0.4);
00145 test_conversion(gl8, glf, 0.4);
00146
00147 test_conversion(glf, i_gray_8, 255);
00148 test_conversion(glf, gray_f, 0.4);
00149 test_conversion(glf, gl8, 142);
00150
00151 test_conversion(gray_f, i_gray_8, 4);
00152 test_conversion(glf, gray_f, 0.4);
00153 }
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172 }