Apply contrast adjustment around midpoint (128) factor > 1.0 increases contrast, < 1.0 decreases
| 31 | // Apply contrast adjustment around midpoint (128) |
| 32 | // factor > 1.0 increases contrast, < 1.0 decreases |
| 33 | static inline int applyContrast(int gray) { |
| 34 | // Integer-based contrast: (gray - 128) * factor + 128 |
| 35 | // Using fixed-point: factor 1.15 ≈ 115/100 |
| 36 | constexpr int factorNum = static_cast<int>(CONTRAST_FACTOR * 100); |
| 37 | int adjusted = ((gray - 128) * factorNum) / 100 + 128; |
| 38 | if (adjusted < 0) adjusted = 0; |
| 39 | if (adjusted > 255) adjusted = 255; |
| 40 | return adjusted; |
| 41 | } |
| 42 | // Combined brightness/contrast/gamma adjustment |
| 43 | int adjustPixel(int gray) { |
| 44 | if (!USE_BRIGHTNESS) return gray; |