MCPcopy Create free account
hub / github.com/crosspoint-reader/crosspoint-reader / applyContrast

Function applyContrast

lib/GfxRenderer/BitmapHelpers.cpp:33–41  ·  view source on GitHub ↗

Apply contrast adjustment around midpoint (128) factor > 1.0 increases contrast, < 1.0 decreases

Source from the content-addressed store, hash-verified

31// Apply contrast adjustment around midpoint (128)
32// factor > 1.0 increases contrast, < 1.0 decreases
33static 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
43int adjustPixel(int gray) {
44 if (!USE_BRIGHTNESS) return gray;

Callers 1

adjustPixelFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected