@@ -109,9 +109,9 @@ void ColorCalibration::calibrate(ColorRgb& color)
109109 {
110110 if (B_RGB != 255 )
111111 {
112- color.red = ((uint32_t )color.red * B_RGB) / 255 ;
113- color.green = ((uint32_t )color.green * B_RGB) / 255 ;
114- color.blue = ((uint32_t )color.blue * B_RGB) / 255 ;
112+ color.red = ((uint32_t )color.red * B_RGB + ( 255 / 2 ) ) / 255 ;
113+ color.green = ((uint32_t )color.green * B_RGB + ( 255 / 2 ) ) / 255 ;
114+ color.blue = ((uint32_t )color.blue * B_RGB + ( 255 / 2 ) ) / 255 ;
115115 }
116116 }
117117 else
@@ -121,17 +121,17 @@ void ColorCalibration::calibrate(ColorRgb& color)
121121 uint32_t nrg = (uint32_t )(255 - ored) * (ogreen);
122122 uint32_t rg = (uint32_t )(ored) * (ogreen);
123123
124- uint8_t black = nrng * (255 - oblue) / 65025 ;
125- uint8_t red = rng * (255 - oblue) / 65025 ;
126- uint8_t green = nrg * (255 - oblue) / 65025 ;
127- uint8_t blue = nrng * (oblue) / 65025 ;
128- uint8_t cyan = nrg * (oblue) / 65025 ;
129- uint8_t magenta = rng * (oblue) / 65025 ;
130- uint8_t yellow = rg * (255 - oblue) / 65025 ;
131- uint8_t white = rg * (oblue) / 65025 ;
124+ uint32_t black = nrng * (255 - oblue);
125+ uint32_t red = rng * (255 - oblue);
126+ uint32_t green = nrg * (255 - oblue);
127+ uint32_t blue = nrng * (oblue);
128+ uint32_t cyan = nrg * (oblue);
129+ uint32_t magenta = rng * (oblue);
130+ uint32_t yellow = rg * (255 - oblue);
131+ uint32_t white = rg * (oblue);
132132
133- uint8_t OR, OG, OB, RR, RG, RB, GR, GG, GB, BR, BG, BB;
134- uint8_t CR, CG, CB, MR, MG, MB, YR, YG, YB, WR, WG, WB;
133+ uint64_t OR, OG, OB, RR, RG, RB, GR, GG, GB, BR, BG, BB;
134+ uint64_t CR, CG, CB, MR, MG, MB, YR, YG, YB, WR, WG, WB;
135135
136136 _blackCalibration->apply (black, 255 , OR, OG, OB);
137137 _redCalibration->apply (red, B_RGB, RR, RG, RB);
@@ -142,9 +142,9 @@ void ColorCalibration::calibrate(ColorRgb& color)
142142 _yellowCalibration->apply (yellow, B_CMY, YR, YG, YB);
143143 _whiteCalibration->apply (white, B_W, WR, WG, WB);
144144
145- color.red = OR + RR + GR + BR + CR + MR + YR + WR;
146- color.green = OG + RG + GG + BG + CG + MG + YG + WG;
147- color.blue = OB + RB + GB + BB + CB + MB + YB + WB;
145+ color.red = std::min (( OR + RR + GR + BR + CR + MR + YR + WR + ( 65025 / 2 )) / 65025 , ( uint64_t ) 255 ) ;
146+ color.green = std::min (( OG + RG + GG + BG + CG + MG + YG + WG + ( 65025 / 2 )) / 65025 , ( uint64_t ) 255 ) ;
147+ color.blue = std::min (( OB + RB + GB + BB + CB + MB + YB + WB + ( 65025 / 2 )) / 65025 , ( uint64_t ) 255 ) ;
148148 }
149149 }
150150 _colorspaceCalibration->applyBacklight (ored, ogreen, oblue);
0 commit comments