00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef PXL_CONVERT_C
00021 #define PXL_CONVERT_C
00022
00023 #include "PXL_Convert.h"
00024
00025
00026 template<class ToType, int fast1, class FromType, int fast2>
00027 inline void
00028 PXL_Convert<ToType,fast1, FromType, fast2>::convert(PXL_Pixel<ToType,fast1> &to,
00029 const PXL_Pixel<FromType,fast2> &from)
00030 {
00031 to = ((float) from);
00032 }
00033
00034
00035 template<>
00036 inline void
00037 PXL_Convert<unsigned char,0,unsigned char,0>::convert(PXL_Pixel<unsigned char,0> &to,
00038 const PXL_Pixel<unsigned char,0> &from)
00039 {
00040 if(to.getBlack() == from.getBlack() && to.getWhite() == from.getWhite())
00041 to.assign((unsigned char) from.getValue());
00042 else
00043 {
00044
00045 float f = (float) from;
00046 to = f;
00047 }
00048 }
00049
00050 template<>
00051 inline void
00052 PXL_Convert<unsigned char,1,unsigned char,0>::convert(PXL_Pixel<unsigned char,1> &to,
00053 const PXL_Pixel<unsigned char,0> &from)
00054 {
00055 if(to.getBlack() == from.getBlack() && to.getWhite() == from.getWhite())
00056 to.assign((unsigned char) from.getValue());
00057 else
00058 {
00059
00060 float f = (float) from;
00061 to = f;
00062 }
00063 }
00064
00065 template<>
00066 inline void
00067 PXL_Convert<unsigned char,0,unsigned char,1>::convert(PXL_Pixel<unsigned char,0> &to,
00068 const PXL_Pixel<unsigned char,1> &from)
00069 {
00070 if(to.getBlack() == from.getBlack() && to.getWhite() == from.getWhite())
00071 to.assign((unsigned char) from.getValue());
00072 else
00073 {
00074
00075 float f = (float) from;
00076 to = f;
00077 }
00078 }
00079
00080 template<>
00081 inline void
00082 PXL_Convert<unsigned char,1,unsigned char,1>::convert(PXL_Pixel<unsigned char,1> &to,
00083 const PXL_Pixel<unsigned char,1> &from)
00084 {
00085 to.assign((unsigned char) from.getValue());
00086 }
00087
00088 template<>
00089 inline void
00090 PXL_Convert<unsigned char,0,unsigned short,0>::convert(PXL_Pixel<unsigned char,0> &to,
00091 const PXL_Pixel<unsigned short,0> &from)
00092 {
00093 if(to.getBlack() == 0 && to.getWhite() == to.maxValue())
00094 to.assign((unsigned char) from);
00095 else
00096 {
00097 float f = (float) from;
00098 to = f;
00099 }
00100 }
00101
00102 template<>
00103 inline void
00104 PXL_Convert<unsigned char,0,unsigned short,1>::convert(PXL_Pixel<unsigned char,0> &to,
00105 const PXL_Pixel<unsigned short,1> &from)
00106 {
00107 if(to.getBlack() == 0 && to.getWhite() == to.maxValue())
00108 to.assign((unsigned char) from);
00109 else
00110 {
00111 float f = (float) from;
00112 to = f;
00113 }
00114 }
00115
00116 template<>
00117 inline void
00118 PXL_Convert<unsigned char,1,unsigned short,0>::convert(PXL_Pixel<unsigned char,1> &to,
00119 const PXL_Pixel<unsigned short,0> &from)
00120 {
00121 to.assign((unsigned char) from);
00122 }
00123
00124 template<>
00125 inline void
00126 PXL_Convert<unsigned char,1,unsigned short,1>::convert(PXL_Pixel<unsigned char,1> &to,
00127 const PXL_Pixel<unsigned short,1> &from)
00128 {
00129 to.assign((unsigned char) from);
00130 }
00131
00132
00133 template<>
00134 inline void
00135 PXL_Convert<unsigned char,0,unsigned int,0>::convert(PXL_Pixel<unsigned char,0> &to,
00136 const PXL_Pixel<unsigned int,0> &from)
00137 {
00138 if(to.getBlack() == 0 && to.getWhite() == to.maxValue())
00139 to.assign((unsigned char) from);
00140 else
00141 to = (float) from;
00142 }
00143
00144 template<>
00145 inline void
00146 PXL_Convert<unsigned char,1,unsigned int,0>::convert(PXL_Pixel<unsigned char,1> &to,
00147 const PXL_Pixel<unsigned int,0> &from)
00148 {
00149 if(to.getBlack() == 0 && to.getWhite() == to.maxValue())
00150 to.assign((unsigned char) from);
00151 else
00152 to = (float) from;
00153 }
00154
00155 template<>
00156 inline void
00157 PXL_Convert<unsigned char,0,unsigned int,1>::convert(PXL_Pixel<unsigned char,0> &to,
00158 const PXL_Pixel<unsigned int,1> &from)
00159 {
00160 if(to.getBlack() == 0 && to.getWhite() == to.maxValue())
00161 to.assign((unsigned char) from);
00162 else
00163 to = (float) from;
00164 }
00165
00166 template<>
00167 inline void
00168 PXL_Convert<unsigned char,1,unsigned int,1>::convert(PXL_Pixel<unsigned char,1> &to,
00169 const PXL_Pixel<unsigned int,1> &from)
00170 {
00171 to.assign((unsigned char) from);
00172 }
00173
00174 template<>
00175 inline void
00176 PXL_Convert<unsigned char,0,float,0>::convert(PXL_Pixel<unsigned char,0> &to,
00177 const PXL_Pixel<float,0> &from)
00178 {
00179 to = (float) from;
00180 }
00181
00182 template<>
00183 inline void
00184 PXL_Convert<unsigned char,1,float,0>::convert(PXL_Pixel<unsigned char,1> &to,
00185 const PXL_Pixel<float,0> &from)
00186 {
00187 to = (float) from;
00188 }
00189
00190 template<>
00191 inline void
00192 PXL_Convert<unsigned char,0,float,1>::convert(PXL_Pixel<unsigned char,0> &to,
00193 const PXL_Pixel<float,1> &from)
00194 {
00195 to = (float) from;
00196 }
00197
00198 template<>
00199 inline void
00200 PXL_Convert<unsigned char,1,float,1>::convert(PXL_Pixel<unsigned char,1> &to,
00201 const PXL_Pixel<float,1> &from)
00202 {
00203 to = (float) from;
00204 }
00205
00206
00207
00208 template<>
00209 inline void
00210 PXL_Convert<unsigned short,0,unsigned char,0>::convert(PXL_Pixel<unsigned short,0>&to,
00211 const PXL_Pixel<unsigned char,0> &from)
00212 {
00213 if(to.getBlack() == 0 && to.getWhite() == to.maxValue())
00214 to.assign((unsigned short) from);
00215 else
00216 {
00217 float f = (float) from;
00218 to = f;
00219 }
00220 }
00221
00222 template<>
00223 inline void
00224 PXL_Convert<unsigned short,1,unsigned char,0>::convert(PXL_Pixel<unsigned short,1>&to,
00225 const PXL_Pixel<unsigned char,0> &from)
00226 {
00227 if(to.getBlack() == 0 && to.getWhite() == to.maxValue())
00228 to.assign((unsigned short) from);
00229 else
00230 {
00231 float f = (float) from;
00232 to = f;
00233 }
00234 }
00235
00236 template<>
00237 inline void
00238 PXL_Convert<unsigned short,0,unsigned char,1>::convert(PXL_Pixel<unsigned short,0>&to,
00239 const PXL_Pixel<unsigned char,1> &from)
00240 {
00241 if(to.getBlack() == 0 && to.getWhite() == to.maxValue())
00242 to.assign((unsigned short) from);
00243 else
00244 {
00245 float f = (float) from;
00246 to = f;
00247 }
00248 }
00249
00250 template<>
00251 inline void
00252 PXL_Convert<unsigned short,1,unsigned char,1>::convert(PXL_Pixel<unsigned short,1>&to,
00253 const PXL_Pixel<unsigned char,1> &from)
00254 {
00255 to.assign((unsigned short) from);
00256 }
00257
00258 template<>
00259 inline void
00260 PXL_Convert<unsigned short,0,unsigned short,0>::convert(PXL_Pixel<unsigned short,0>&to,
00261 const PXL_Pixel<unsigned short,0> &from)
00262 {
00263 if(to.getBlack() == from.getBlack() && to.getWhite() == from.getWhite())
00264 to.assign(from.getValue());
00265 else
00266 {
00267
00268 to = (float) from;
00269 }
00270 }
00271
00272 template<>
00273 inline void
00274 PXL_Convert<unsigned short,1,unsigned short,0>::convert(PXL_Pixel<unsigned short,1>&to,
00275 const PXL_Pixel<unsigned short,0> &from)
00276 {
00277 if(to.getBlack() == from.getBlack() && to.getWhite() == from.getWhite())
00278 to.assign(from.getValue());
00279 else
00280 {
00281
00282 to = (float) from;
00283 }
00284 }
00285
00286 template<>
00287 inline void
00288 PXL_Convert<unsigned short,0,unsigned short,1>::convert(PXL_Pixel<unsigned short,0>&to,
00289 const PXL_Pixel<unsigned short,1> &from)
00290 {
00291 if(to.getBlack() == from.getBlack() && to.getWhite() == from.getWhite())
00292 to.assign(from.getValue());
00293 else
00294 {
00295
00296 to = (float) from;
00297 }
00298 }
00299
00300 template<>
00301 inline void
00302 PXL_Convert<unsigned short,1,unsigned short,1>::convert(PXL_Pixel<unsigned short,1>&to,
00303 const PXL_Pixel<unsigned short,1> &from)
00304 {
00305 to.assign(from.getValue());
00306 }
00307
00308 template<>
00309 inline void
00310 PXL_Convert<unsigned short,0,unsigned int,0>::convert(PXL_Pixel<unsigned short,0> &to,
00311 const PXL_Pixel<unsigned int,0> &from)
00312 {
00313 if(to.getBlack() == 0 && to.getWhite() == to.maxValue())
00314 to.assign((unsigned short) from);
00315 else
00316 to = (float) from;
00317 }
00318
00319 template<>
00320 inline void
00321 PXL_Convert<unsigned short,1,unsigned int,0>::convert(PXL_Pixel<unsigned short,1> &to,
00322 const PXL_Pixel<unsigned int,0> &from)
00323 {
00324 if(to.getBlack() == 0 && to.getWhite() == to.maxValue())
00325 to.assign((unsigned short) from);
00326 else
00327 to = (float) from;
00328 }
00329
00330 template<>
00331 inline void
00332 PXL_Convert<unsigned short,0,unsigned int,1>::convert(PXL_Pixel<unsigned short,0> &to,
00333 const PXL_Pixel<unsigned int,1> &from)
00334 {
00335 if(to.getBlack() == 0 && to.getWhite() == to.maxValue())
00336 to.assign((unsigned short) from);
00337 else
00338 to = (float) from;
00339 }
00340
00341 template<>
00342 inline void
00343 PXL_Convert<unsigned short,1,unsigned int,1>::convert(PXL_Pixel<unsigned short,1> &to,
00344 const PXL_Pixel<unsigned int,1> &from)
00345 {
00346 to.assign((unsigned short) from);
00347 }
00348
00349
00350 template<>
00351 inline void
00352 PXL_Convert<unsigned int,0,unsigned char,0>::convert(PXL_Pixel<unsigned int,0> &to,
00353 const PXL_Pixel<unsigned char,0> &from)
00354 {
00355 if(to.getBlack() == 0 && to.getWhite() == to.maxValue())
00356 to.assign((unsigned int) from);
00357 else
00358 to = (float) from;
00359 }
00360
00361 template<>
00362 inline void
00363 PXL_Convert<unsigned int,1,unsigned char,0>::convert(PXL_Pixel<unsigned int,1> &to,
00364 const PXL_Pixel<unsigned char,0> &from)
00365 {
00366 if(to.getBlack() == 0 && to.getWhite() == to.maxValue())
00367 to.assign(from);
00368 else
00369 to = (float) from;
00370 }
00371
00372 template<>
00373 inline void
00374 PXL_Convert<unsigned int,0,unsigned char,1>::convert(PXL_Pixel<unsigned int,0> &to,
00375 const PXL_Pixel<unsigned char,1> &from)
00376 {
00377 if(to.getBlack() == 0 && to.getWhite() == to.maxValue())
00378 to.assign((unsigned int) from);
00379 else
00380 to = ((float) from);
00381 }
00382
00383 template<>
00384 inline void
00385 PXL_Convert<unsigned int,1,unsigned char,1>::convert(PXL_Pixel<unsigned int,1> &to,
00386 const PXL_Pixel<unsigned char,1> &from)
00387 {
00388 to.assign((unsigned int) from);
00389 }
00390
00391 template<>
00392 inline void
00393 PXL_Convert<unsigned int,0,unsigned short,0>::convert(PXL_Pixel<unsigned int,0> &to,
00394 const PXL_Pixel<unsigned short,0> &from)
00395 {
00396 if(to.getBlack() == 0 && to.getWhite() == to.maxValue())
00397 to.set((unsigned int) from);
00398 else
00399 to = ((float) from);
00400 }
00401
00402 template<>
00403 inline void
00404 PXL_Convert<unsigned int,1,unsigned short,0>::convert(PXL_Pixel<unsigned int,1> &to,
00405 const PXL_Pixel<unsigned short,0> &from)
00406 {
00407 if(to.getBlack() == 0 && to.getWhite() == to.maxValue())
00408 to.set(from);
00409 else
00410 to = ((float) from);
00411 }
00412
00413 template<>
00414 inline void
00415 PXL_Convert<unsigned int,0,unsigned short,1>::convert(PXL_Pixel<unsigned int,0> &to,
00416 const PXL_Pixel<unsigned short,1> &from)
00417 {
00418 if(to.getBlack() == 0 && to.getWhite() == to.maxValue())
00419 to.assign(from);
00420 else
00421 to = ((float) from);
00422 }
00423
00424 template<>
00425 inline void
00426 PXL_Convert<unsigned int,1,unsigned short,1>::convert(PXL_Pixel<unsigned int,1> &to,
00427 const PXL_Pixel<unsigned short,1> &from)
00428 {
00429 to = ((float) from);
00430 }
00431
00432 template<>
00433 inline void
00434 PXL_Convert<unsigned int,0,unsigned int,0>::convert(PXL_Pixel<unsigned int,0> &to,
00435 const PXL_Pixel<unsigned int,0> &from)
00436 {
00437 if(to.getBlack() == from.getBlack() && to.getWhite() == from.getWhite())
00438 {
00439 to.set(from.getValue());
00440 }
00441 else
00442 {
00443
00444 to = ((float) from);
00445 }
00446 }
00447
00448 template<>
00449 inline void
00450 PXL_Convert<unsigned int,1,unsigned int,0>::convert(PXL_Pixel<unsigned int,1> &to,
00451 const PXL_Pixel<unsigned int,0> &from)
00452 {
00453 if(to.getBlack() == from.getBlack() && to.getWhite() == from.getWhite())
00454 {
00455 to.set(from.getValue());
00456 }
00457 else
00458 {
00459
00460 to = ((float) from);
00461 }
00462 }
00463
00464 template<>
00465 inline void
00466 PXL_Convert<unsigned int,0,unsigned int,1>::convert(PXL_Pixel<unsigned int,0> &to,
00467 const PXL_Pixel<unsigned int,1> &from)
00468 {
00469 if(to.getBlack() == from.getBlack() && to.getWhite() == from.getWhite())
00470 {
00471 to.set(from.getValue());
00472 }
00473 else
00474 {
00475
00476 to = ((float) from);
00477 }
00478 }
00479
00480 template<>
00481 inline void
00482 PXL_Convert<unsigned int,1,unsigned int,1>::convert(PXL_Pixel<unsigned int,1> &to,
00483 const PXL_Pixel<unsigned int,1> &from)
00484 {
00485 to.set(from.getValue());
00486 }
00487
00488 template<>
00489 inline void
00490 PXL_Convert<fpreal16,1,float,1>::convert(PXL_Pixel<fpreal16,1> &to,
00491 const PXL_Pixel<float,1> &from)
00492 {
00493 fpreal16 val = from.getValue();
00494 to.set(val);
00495 }
00496
00497 template<>
00498 inline void
00499 PXL_Convert<fpreal16,0,float,1>::convert(PXL_Pixel<fpreal16,0> &to,
00500 const PXL_Pixel<float,1> &from)
00501 {
00502 fpreal16 val = from.getValue();
00503 to.set(val);
00504 }
00505
00506 template<>
00507 inline void
00508 PXL_Convert<fpreal16,0,float,0>::convert(PXL_Pixel<fpreal16,0> &to,
00509 const PXL_Pixel<float,0> &from)
00510 {
00511 fpreal16 val = from.getValue();
00512 to.set(val);
00513 }
00514
00515 template<>
00516 inline void
00517 PXL_Convert<fpreal16,1,float,0>::convert(PXL_Pixel<fpreal16,1> &to,
00518 const PXL_Pixel<float,0> &from)
00519 {
00520 fpreal16 val = from.getValue();
00521 to.set(val);
00522 }
00523
00524 #endif