00001 #include "vuFixelType.h" 00002 #include <iostream.h> 00003 00004 template <class TYPE> 00005 TYPE vuFixelType<TYPE>::getMinValue() 00006 { 00007 cerr << "vuFixelType.getMinValue: not implemented for this type" << endl; 00008 throw "vuFixelType.getMinValue: not implemented for this type"; 00009 return (TYPE)0; 00010 } 00011 00012 template <class TYPE> 00013 TYPE vuFixelType<TYPE>::getMaxValue() 00014 { 00015 cerr << "vuFixelType.getMaxValue: not implemented for this type" << endl; 00016 throw "vuFixelType.getMaxValue: not implemented for this type"; 00017 return (TYPE)0; 00018 } 00019 00020 template <class TYPE> 00021 TYPE vuFixelType<TYPE>::getPosInfinity() 00022 { 00023 cerr << "vuFixelType.getPosInfinity: not implemented for this type" << endl; 00024 throw "vuFixelType.getMinValue: not implemented for this type"; 00025 return (TYPE)0; 00026 } 00027 00028 template <class TYPE> 00029 TYPE vuFixelType<TYPE>::getNegInfinity() 00030 { 00031 cerr << "vuFixelType.getNegInfinity: not implemented for this type" << endl; 00032 throw "vuFixelType.getNegInfinity: not implemented for this type"; 00033 return (TYPE)0; 00034 } 00035 00036 template <class TYPE> 00037 bool vuFixelType<TYPE>::isByte() 00038 { 00039 return false; 00040 } 00041 00042 template <class TYPE> 00043 bool vuFixelType<TYPE>::isFloat() 00044 { 00045 return false; 00046 } 00047 00048 // -------------------------------------------------------------------------- 00049 // --- float template instance ---------------------------------------------- 00050 // -------------------------------------------------------------------------- 00051 00052 float vuFixelType<float>::getMinValue() 00053 { 00054 return 0.0f; 00055 } 00056 00057 float vuFixelType<float>::getMaxValue() 00058 { 00059 return 1.0f; 00060 } 00061 00062 float vuFixelType<float>::getPosInfinity() 00063 { 00064 return 1000000000000.0f; 00065 } 00066 00067 float vuFixelType<float>::getNegInfinity() 00068 { 00069 return -1000000000000.0f; 00070 } 00071 00072 bool vuFixelType<float>::isFloat() 00073 { 00074 return true; 00075 } 00076 00077 // -------------------------------------------------------------------------- 00078 // --- byte template instance ---------------------------------------------- 00079 // -------------------------------------------------------------------------- 00080 00081 byte vuFixelType<byte>::getMinValue() 00082 { 00083 return 0; 00084 } 00085 00086 byte vuFixelType<byte>::getMaxValue() 00087 { 00088 return 255; 00089 } 00090 00091 byte vuFixelType<byte>::getPosInfinity() 00092 { 00093 return 255; 00094 } 00095 00096 byte vuFixelType<byte>::getNegInfinity() 00097 { 00098 return 0; 00099 } 00100 00101 bool vuFixelType<byte>::isByte() 00102 { 00103 return true; 00104 } 00105 00106 // *** vuFixelTypeConverter ************************************************** 00107 00108 byte vuFixelTypeConverter<byte,byte>::getValue(byte value) 00109 { 00110 return value; 00111 } 00112 00113 // assuming return value: [0.0 .. 1.0] 00114 float vuFixelTypeConverter<byte,float>::getValue(byte value) 00115 { 00116 return ((float)value)/255.0f; 00117 } 00118 00119 // assuming value = [0.0 .. 1.0] 00120 byte vuFixelTypeConverter<float,byte>::getValue(float value) 00121 { 00122 return (byte)(value * 255); 00123 } 00124 00125 float vuFixelTypeConverter<float,float>::getValue(float value) 00126 { 00127 return value; 00128 }