comparison OrthancStone/Sources/Scene2D/Internals/OpenGLFloatTextureProgram.cpp @ 1571:85e117739eca

cppcheck
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 21 Sep 2020 17:46:39 +0200
parents 244ad1e4e76a
children 92fca2b3ba3d
comparison
equal deleted inserted replaced
1570:9a04f42098a3 1571:85e117739eca
60 namespace OrthancStone 60 namespace OrthancStone
61 { 61 {
62 namespace Internals 62 namespace Internals
63 { 63 {
64 OpenGLFloatTextureProgram::Data::Data( 64 OpenGLFloatTextureProgram::Data::Data(
65 OpenGL::IOpenGLContext& context 65 OpenGL::IOpenGLContext& context,
66 , const Orthanc::ImageAccessor& texture 66 const Orthanc::ImageAccessor& texture,
67 , bool isLinearInterpolation) 67 bool isLinearInterpolation) :
68 : texture_(context) 68 texture_(context),
69 , offset_(0.0f) 69 offset_(0.0f),
70 , slope_(0.0f) 70 slope_(0.0f)
71 { 71 {
72 if (texture.GetFormat() != Orthanc::PixelFormat_Float32) 72 if (texture.GetFormat() != Orthanc::PixelFormat_Float32)
73 { 73 {
74 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat); 74 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat);
75 } 75 }
105 * At (*), the floating-point "value" is reconstructed as 105 * At (*), the floating-point "value" is reconstructed as
106 * "value = texture * slope + offset". 106 * "value = texture * slope + offset".
107 * <=> texture = (value - offset) / slope 107 * <=> texture = (value - offset) / slope
108 **/ 108 **/
109 109
110 float texture = (*p - offset_) / slope_; 110 float value = (*p - offset_) / slope_;
111 if (texture < 0) 111 if (value < 0)
112 { 112 {
113 texture = 0; 113 value = 0;
114 } 114 }
115 else if (texture >= 65535.0f) 115 else if (value >= 65535.0f)
116 { 116 {
117 texture = 65535.0f; 117 value = 65535.0f;
118 } 118 }
119 119
120 uint16_t t = static_cast<uint16_t>(texture); 120 uint16_t t = static_cast<uint16_t>(value);
121 121
122 q[0] = t / 256; // red 122 q[0] = t / 256; // red
123 q[1] = t % 256; // green 123 q[1] = t % 256; // green
124 q[2] = 0; // blue is unused 124 q[2] = 0; // blue is unused
125 125