MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / clamp

Function clamp

extern/toojpeg/toojpeg.cpp:193–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

191// restrict a value to the interval [minimum, maximum]
192template <typename Number, typename Limit>
193Number clamp(Number value, Limit minValue, Limit maxValue)
194{
195 if (value <= minValue) return minValue; // never smaller than the minimum
196 if (value >= maxValue) return maxValue; // never bigger than the maximum
197 return value; // value was inside interval, keep it
198}
199
200// convert from RGB to YCbCr, constants are similar to ITU-R, see https://en.wikipedia.org/wiki/YCbCr#JPEG_conversion
201float rgb2y (float r, float g, float b) { return +0.299f * r +0.587f * g +0.114f * b; }

Callers 1

writeJpegFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected