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 template <>
00027 inline void ConvertPixel<PXF_L8, PXF_L8>(const uchar* pSrc, uchar* pDest)
00028 {
00029 *pDest = *pSrc;
00030 }
00031
00032 template <>
00033 inline void ConvertPixel<PXF_L8, PXF_A8L8>(const uchar* pSrc, uchar* pDest)
00034 {
00035 pDest[0] = *pSrc;
00036 pDest[1] = 0xFF;
00037 }
00038
00039 template <>
00040 inline void ConvertPixel<PXF_L8, PXF_A1R5G5B5>(const uchar* pSrc, uchar* pDest)
00041 {
00042 *reinterpret_cast<ushort*>(pDest) = 0x8000 |
00043 ((*pSrc >> 3) << 10) |
00044 ((*pSrc >> 3) << 5) |
00045 ((*pSrc >> 3) << 0);
00046 }
00047
00048 template <>
00049 inline void ConvertPixel<PXF_L8, PXF_A4R4G4B4>(const uchar* pSrc, uchar* pDest)
00050 {
00051 pDest[0] = (*pSrc & 0xF0) | (*pSrc >> 4);
00052 pDest[1] = 0xF0 | (*pSrc >> 4);
00053 }
00054
00055 template <>
00056 inline void ConvertPixel<PXF_L8, PXF_R8G8B8>(const uchar* pSrc, uchar* pDest)
00057 {
00058 pDest[0] = *pSrc;
00059 pDest[1] = *pSrc;
00060 pDest[2] = *pSrc;
00061 }
00062
00063 template <>
00064 inline void ConvertPixel<PXF_L8, PXF_A8R8G8B8>(const uchar* pSrc, uchar* pDest)
00065 {
00066 pDest[0] = *pSrc;
00067 pDest[1] = *pSrc;
00068 pDest[2] = *pSrc;
00069 pDest[3] = 0xFF;
00070 }
00071
00072
00073
00074 template <>
00075 inline void ConvertPixel<PXF_A8L8, PXF_L8>(const uchar* pSrc, uchar* pDest)
00076 {
00077 *pDest = pSrc[0];
00078 }
00079
00080 template <>
00081 inline void ConvertPixel<PXF_A8L8, PXF_A8L8>(const uchar* pSrc, uchar* pDest)
00082 {
00083 pDest[0] = pSrc[0];
00084 pDest[1] = pSrc[1];
00085 }
00086
00087 template <>
00088 inline void ConvertPixel<PXF_A8L8, PXF_A1R5G5B5>(const uchar* pSrc, uchar* pDest)
00089 {
00090 *reinterpret_cast<ushort*>(pDest) = ((pSrc[1] >> 7) << 15) |
00091 ((pSrc[0] >> 3) << 10) |
00092 ((pSrc[0] >> 3) << 5) |
00093 ((pSrc[0] >> 3) << 0);
00094 }
00095
00096 template <>
00097 inline void ConvertPixel<PXF_A8L8, PXF_A4R4G4B4>(const uchar* pSrc, uchar* pDest)
00098 {
00099 pDest[0] = (pSrc[0] & 0xF0) | (pSrc[0] >> 4);
00100 pDest[1] = (pSrc[1] & 0xF0) | (pSrc[0] >> 4);
00101 }
00102
00103 template <>
00104 inline void ConvertPixel<PXF_A8L8, PXF_R8G8B8>(const uchar* pSrc, uchar* pDest)
00105 {
00106 pDest[0] = pSrc[0];
00107 pDest[1] = pSrc[0];
00108 pDest[2] = pSrc[0];
00109 }
00110
00111 template <>
00112 inline void ConvertPixel<PXF_A8L8, PXF_A8R8G8B8>(const uchar* pSrc, uchar* pDest)
00113 {
00114 pDest[0] = pSrc[0];
00115 pDest[1] = pSrc[0];
00116 pDest[2] = pSrc[0];
00117 pDest[3] = pSrc[1];
00118 }
00119
00120
00121
00122 template <>
00123 inline void ConvertPixel<PXF_A1R5G5B5, PXF_L8>(const uchar* pSrc, uchar* pDest)
00124 {
00125 ushort Pix = *reinterpret_cast<const ushort*>(pSrc);
00126 *pDest = static_cast<uchar>(((Pix & 0x7C00) >> 7) * 0.30 +
00127 ((Pix & 0x03E0) >> 2) * 0.59 +
00128 ((Pix & 0x001F) << 3) * 0.11);
00129 }
00130
00131 template <>
00132 inline void ConvertPixel<PXF_A1R5G5B5, PXF_A8L8>(const uchar* pSrc, uchar* pDest)
00133 {
00134 ushort Pix = *reinterpret_cast<const ushort*>(pSrc);
00135 pDest[0] = static_cast<uchar>(((Pix & 0x7C00) >> 7) * 0.30 +
00136 ((Pix & 0x03E0) >> 2) * 0.59 +
00137 ((Pix & 0x001F) << 3) * 0.11);
00138 pDest[1] = pSrc[1] & 0x8000 ? 0xFF : 0x00;
00139 }
00140
00141 template <>
00142 inline void ConvertPixel<PXF_A1R5G5B5, PXF_A1R5G5B5>(const uchar* pSrc, uchar* pDest)
00143 {
00144 pDest[0] = pSrc[0];
00145 pDest[1] = pSrc[1];
00146 }
00147
00148 template <>
00149 inline void ConvertPixel<PXF_A1R5G5B5, PXF_A4R4G4B4>(const uchar* pSrc, uchar* pDest)
00150 {
00151 ushort Pix = *reinterpret_cast<const ushort*>(pSrc);
00152 pDest[1] = (Pix & 0x8000 ? 0xF0 : 0x00) | ((Pix & 0x7C00) >> 11);
00153 pDest[0] = ((Pix & 0x03C0) >> 2) | ((Pix & 0x001F) >> 1);
00154 }
00155
00156 template <>
00157 inline void ConvertPixel<PXF_A1R5G5B5, PXF_R8G8B8>(const uchar* pSrc, uchar* pDest)
00158 {
00159 ushort Pix = *reinterpret_cast<const ushort*>(pSrc);
00160 pDest[2] = (Pix & 0x7C00) >> 7;
00161 pDest[1] = (Pix & 0x03E0) >> 2;
00162 pDest[0] = (Pix & 0x001F) << 3;
00163 }
00164
00165 template <>
00166 inline void ConvertPixel<PXF_A1R5G5B5, PXF_A8R8G8B8>(const uchar* pSrc, uchar* pDest)
00167 {
00168 ushort Pix = *reinterpret_cast<const ushort*>(pSrc);
00169 pDest[3] = (Pix & 0x8000) >> 8;
00170 pDest[2] = (Pix & 0x7C00) >> 7;
00171 pDest[1] = (Pix & 0x03E0) >> 2;
00172 pDest[0] = (Pix & 0x001F) << 3;
00173 }
00174
00175
00176 template <>
00177 inline void ConvertPixel<PXF_A4R4G4B4, PXF_L8>(const uchar* pSrc, uchar* pDest)
00178 {
00179 *pDest = static_cast<uchar>(((pSrc[1] & 0x0F) << 4) * 0.30 +
00180 ((pSrc[0] & 0xF0) >> 0) * 0.59 +
00181 ((pSrc[0] & 0x0F) << 4) * 0.11);
00182 }
00183
00184 template <>
00185 inline void ConvertPixel<PXF_A4R4G4B4, PXF_A8L8>(const uchar* pSrc, uchar* pDest)
00186 {
00187 pDest[0] = static_cast<uchar>(((pSrc[1] & 0x0F) << 4) * 0.30 +
00188 ((pSrc[0] & 0xF0) >> 0) * 0.59 +
00189 ((pSrc[0] & 0x0F) << 4) * 0.11);
00190 pDest[1] = pSrc[1] & 0xF0;
00191 }
00192
00193 template <>
00194 inline void ConvertPixel<PXF_A4R4G4B4, PXF_A1R5G5B5>(const uchar* pSrc, uchar* pDest)
00195 {
00196 *reinterpret_cast<ushort*>(pDest) = ((pSrc[1] & 0x80) << 8) |
00197 ((pSrc[1] & 0x0F) << 11) |
00198 ((pSrc[0] & 0xF0) << 2) |
00199 ((pSrc[0] & 0x0F) << 1);
00200 }
00201
00202 template <>
00203 inline void ConvertPixel<PXF_A4R4G4B4, PXF_A4R4G4B4>(const uchar* pSrc, uchar* pDest)
00204 {
00205 pDest[0] = pSrc[0];
00206 pDest[1] = pSrc[1];
00207 }
00208
00209 template <>
00210 inline void ConvertPixel<PXF_A4R4G4B4, PXF_R8G8B8>(const uchar* pSrc, uchar* pDest)
00211 {
00212 pDest[0] = (pSrc[0] & 0x0F) << 4;
00213 pDest[1] = (pSrc[0] & 0xF0);
00214 pDest[2] = (pSrc[1] & 0x0F) << 4;
00215 }
00216
00217 template <>
00218 inline void ConvertPixel<PXF_A4R4G4B4, PXF_A8R8G8B8>(const uchar* pSrc, uchar* pDest)
00219 {
00220 pDest[0] = (pSrc[0] & 0x0F) << 4;
00221 pDest[1] = (pSrc[0] & 0xF0);
00222 pDest[2] = (pSrc[1] & 0x0F) << 4;
00223 pDest[3] = (pSrc[1] & 0xF0);
00224 }
00225
00226
00227
00228 template <>
00229 inline void ConvertPixel<PXF_R8G8B8, PXF_L8>(const uchar* pSrc, uchar* pDest)
00230 {
00231 *pDest = static_cast<uchar>(pSrc[2] * 0.30 + pSrc[1] * 0.59 + pSrc[0] * 0.11);
00232 }
00233
00234 template <>
00235 inline void ConvertPixel<PXF_R8G8B8, PXF_A8L8>(const uchar* pSrc, uchar* pDest)
00236 {
00237 pDest[0] = static_cast<uchar>(pSrc[2] * 0.30 + pSrc[1] * 0.59 + pSrc[0] * 0.11);
00238 pDest[1] = 0xFF;
00239 }
00240
00241 template <>
00242 inline void ConvertPixel<PXF_R8G8B8, PXF_A1R5G5B5>(const uchar* pSrc, uchar* pDest)
00243 {
00244 *reinterpret_cast<ushort*>(pDest) = 0x8000 |
00245 ((pSrc[2] >> 3) << 10) |
00246 ((pSrc[1] >> 3) << 5) |
00247 ((pSrc[0] >> 3) << 0);
00248 }
00249
00250 template <>
00251 inline void ConvertPixel<PXF_R8G8B8, PXF_A4R4G4B4>(const uchar* pSrc, uchar* pDest)
00252 {
00253 pDest[0] = (pSrc[1] & 0xF0) | (pSrc[0] >> 4);
00254 pDest[1] = 0xF0 | (pSrc[2] >> 4);
00255 }
00256
00257 template <>
00258 inline void ConvertPixel<PXF_R8G8B8, PXF_R8G8B8>(const uchar* pSrc, uchar* pDest)
00259 {
00260 pDest[0] = pSrc[0];
00261 pDest[1] = pSrc[1];
00262 pDest[2] = pSrc[2];
00263 }
00264
00265 template <>
00266 inline void ConvertPixel<PXF_R8G8B8, PXF_A8R8G8B8>(const uchar* pSrc, uchar* pDest)
00267 {
00268 pDest[0] = pSrc[0];
00269 pDest[1] = pSrc[1];
00270 pDest[2] = pSrc[2];
00271 pDest[3] = 0xFF;
00272 }
00273
00274
00275
00276 template <>
00277 inline void ConvertPixel<PXF_A8R8G8B8, PXF_L8>(const uchar* pSrc, uchar* pDest)
00278 {
00279 *pDest = static_cast<uchar>(pSrc[2] * 0.30 + pSrc[1] * 0.59 + pSrc[0] * 0.11);
00280 }
00281
00282 template <>
00283 inline void ConvertPixel<PXF_A8R8G8B8, PXF_A8L8>(const uchar* pSrc, uchar* pDest)
00284 {
00285 pDest[0] = static_cast<uchar>(pSrc[2] * 0.30 + pSrc[1] * 0.59 + pSrc[0] * 0.11);
00286 pDest[1] = pSrc[3];
00287 }
00288
00289 template <>
00290 inline void ConvertPixel<PXF_A8R8G8B8, PXF_A1R5G5B5>(const uchar* pSrc, uchar* pDest)
00291 {
00292 *reinterpret_cast<ushort*>(pDest) = ((pSrc[3] >> 7) << 15) |
00293 ((pSrc[2] >> 3) << 10) |
00294 ((pSrc[1] >> 3) << 5) |
00295 ((pSrc[0] >> 3) << 0);
00296 }
00297
00298 template <>
00299 inline void ConvertPixel<PXF_A8R8G8B8, PXF_A4R4G4B4>(const uchar* pSrc, uchar* pDest)
00300 {
00301 pDest[0] = (pSrc[1] & 0xF0) | (pSrc[0] >> 4);
00302 pDest[1] = (pSrc[3] & 0xF0) | (pSrc[2] >> 4);
00303 }
00304
00305 template <>
00306 inline void ConvertPixel<PXF_A8R8G8B8, PXF_R8G8B8>(const uchar* pSrc, uchar* pDest)
00307 {
00308 pDest[0] = pSrc[0];
00309 pDest[1] = pSrc[1];
00310 pDest[2] = pSrc[2];
00311 }
00312
00313 template <>
00314 inline void ConvertPixel<PXF_A8R8G8B8, PXF_A8R8G8B8>(const uchar* pSrc, uchar* pDest)
00315 {
00316 pDest[0] = pSrc[0];
00317 pDest[1] = pSrc[1];
00318 pDest[2] = pSrc[2];
00319 pDest[3] = pSrc[3];
00320 }