MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / stbi__clamp

Function stbi__clamp

Source/Utils/stb_image.h:2415–2423  ·  view source on GitHub ↗

take a -128..127 value and stbi__clamp it and convert to 0..255

Source from the content-addressed store, hash-verified

2413
2414// take a -128..127 value and stbi__clamp it and convert to 0..255
2415stbi_inline static stbi_uc stbi__clamp(int x)
2416{
2417 // trick to use a single test to catch both cases
2418 if ((unsigned int) x > 255) {
2419 if (x < 0) return 0;
2420 if (x > 255) return 255;
2421 }
2422 return (stbi_uc) x;
2423}
2424
2425#define stbi__f2f(x) ((int) (((x) * 4096 + 0.5)))
2426#define stbi__fsh(x) ((x) * 4096)

Callers 1

stbi__idct_blockFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected