comparison Core/Images/PixelTraits.h @ 2645:89b789366596

Grayscale64 pixel format
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 31 May 2018 08:31:22 +0200
parents 5aa787a03e7d
children 65699fcb4e99
comparison
equal deleted inserted replaced
2637:5094369664f0 2645:89b789366596
148 { 148 {
149 }; 149 };
150 150
151 151
152 template <> 152 template <>
153 struct PixelTraits<PixelFormat_Grayscale32> :
154 public IntegerPixelTraits<PixelFormat_Grayscale32, uint32_t>
155 {
156 };
157
158
159 template <>
160 struct PixelTraits<PixelFormat_Grayscale64> :
161 public IntegerPixelTraits<PixelFormat_Grayscale64, uint64_t>
162 {
163 };
164
165
166 template <>
153 struct PixelTraits<PixelFormat_RGB24> 167 struct PixelTraits<PixelFormat_RGB24>
154 { 168 {
155 struct PixelType 169 struct PixelType
156 { 170 {
157 uint8_t red_; 171 uint8_t red_;
262 target.green_ = v; 276 target.green_ = v;
263 target.red_ = v; 277 target.red_ = v;
264 target.alpha_ = 255; 278 target.alpha_ = 255;
265 } 279 }
266 }; 280 };
281
282
283 template <>
284 struct PixelTraits<PixelFormat_Float32>
285 {
286 typedef float PixelType;
287
288 ORTHANC_FORCE_INLINE
289 static PixelFormat GetPixelFormat()
290 {
291 return PixelFormat_Float32;
292 }
293
294 ORTHANC_FORCE_INLINE
295 static void SetZero(PixelType& target)
296 {
297 target = 0.0f;
298 }
299
300 ORTHANC_FORCE_INLINE
301 static void Copy(PixelType& target,
302 const PixelType& source)
303 {
304 target = source;
305 }
306
307 ORTHANC_FORCE_INLINE
308 static bool IsEqual(const PixelType& a,
309 const PixelType& b)
310 {
311 float tmp = (a - b);
312
313 if (tmp < 0)
314 {
315 tmp = -tmp;
316 }
317
318 return tmp <= std::numeric_limits<float>::epsilon();
319 }
320
321 ORTHANC_FORCE_INLINE
322 static void FloatToPixel(PixelType& target,
323 float value)
324 {
325 target = value;
326 }
327
328 ORTHANC_FORCE_INLINE
329 static float PixelToFloat(const PixelType& source)
330 {
331 return source;
332 }
333 };
267 } 334 }