take a -128..127 value and stbi__clamp it and convert to 0..255
| 2413 | |
| 2414 | // take a -128..127 value and stbi__clamp it and convert to 0..255 |
| 2415 | stbi_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) |