Mercurial > hg > orthanc
diff 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 |
line wrap: on
line diff
--- a/Core/Images/PixelTraits.h Mon May 28 10:54:59 2018 +0200 +++ b/Core/Images/PixelTraits.h Thu May 31 08:31:22 2018 +0200 @@ -150,6 +150,20 @@ template <> + struct PixelTraits<PixelFormat_Grayscale32> : + public IntegerPixelTraits<PixelFormat_Grayscale32, uint32_t> + { + }; + + + template <> + struct PixelTraits<PixelFormat_Grayscale64> : + public IntegerPixelTraits<PixelFormat_Grayscale64, uint64_t> + { + }; + + + template <> struct PixelTraits<PixelFormat_RGB24> { struct PixelType @@ -264,4 +278,57 @@ target.alpha_ = 255; } }; + + + template <> + struct PixelTraits<PixelFormat_Float32> + { + typedef float PixelType; + + ORTHANC_FORCE_INLINE + static PixelFormat GetPixelFormat() + { + return PixelFormat_Float32; + } + + ORTHANC_FORCE_INLINE + static void SetZero(PixelType& target) + { + target = 0.0f; + } + + ORTHANC_FORCE_INLINE + static void Copy(PixelType& target, + const PixelType& source) + { + target = source; + } + + ORTHANC_FORCE_INLINE + static bool IsEqual(const PixelType& a, + const PixelType& b) + { + float tmp = (a - b); + + if (tmp < 0) + { + tmp = -tmp; + } + + return tmp <= std::numeric_limits<float>::epsilon(); + } + + ORTHANC_FORCE_INLINE + static void FloatToPixel(PixelType& target, + float value) + { + target = value; + } + + ORTHANC_FORCE_INLINE + static float PixelToFloat(const PixelType& source) + { + return source; + } + }; }