Do not generate negative values if raw values are less than black level, #5562

This commit is contained in:
Ingo Weyrich
2019-12-12 20:05:43 +01:00
parent 637e8454ef
commit 4d72fc0b5b

View File

@@ -2543,12 +2543,10 @@ void RawImageSource::scaleColors(int winx, int winy, int winw, int winh, const R
for (int row = winy; row < winy + winh; row ++)
{
for (int col = winx; col < winx + winw; col++) {
float val = rawData[row][col];
int c = FC(row, col); // three colors, 0=R, 1=G, 2=B
int c4 = ( c == 1 && !(row & 1) ) ? 3 : c; // four colors, 0=R, 1=G1, 2=B, 3=G2
val -= cblacksom[c4];
val *= scale_mul[c4];
rawData[row][col] = (val);
const int c = FC(row, col); // three colors, 0=R, 1=G, 2=B
const int c4 = ( c == 1 && !(row & 1) ) ? 3 : c; // four colors, 0=R, 1=G1, 2=B, 3=G2
const float val = max(0.f, rawData[row][col] - cblacksom[c4]) * scale_mul[c4];
rawData[row][col] = val;
tmpchmax[c] = max(tmpchmax[c], val);
}
}
@@ -2575,10 +2573,8 @@ void RawImageSource::scaleColors(int winx, int winy, int winw, int winh, const R
for (int row = winy; row < winy + winh; row ++)
{
for (int col = winx; col < winx + winw; col++) {
float val = rawData[row][col];
val -= cblacksom[0];
val *= scale_mul[0];
rawData[row][col] = (val);
const float val = max(0.f, rawData[row][col] - cblacksom[0]) * scale_mul[0];
rawData[row][col] = val;
tmpchmax = max(tmpchmax, val);
}
}
@@ -2604,12 +2600,9 @@ void RawImageSource::scaleColors(int winx, int winy, int winw, int winh, const R
for (int row = winy; row < winy + winh; row ++)
{
for (int col = winx; col < winx + winw; col++) {
float val = rawData[row][col];
int c = ri->XTRANSFC(row, col);
val -= cblacksom[c];
val *= scale_mul[c];
rawData[row][col] = (val);
const int c = ri->XTRANSFC(row, col);
const float val = max(0.f, rawData[row][col] - cblacksom[c]) * scale_mul[c];
rawData[row][col] = val;
tmpchmax[c] = max(tmpchmax[c], val);
}
}
@@ -2638,10 +2631,8 @@ void RawImageSource::scaleColors(int winx, int winy, int winw, int winh, const R
{
for (int col = winx; col < winx + winw; col++) {
for (int c = 0; c < 3; c++) { // three colors, 0=R, 1=G, 2=B
float val = rawData[row][3 * col + c];
val -= cblacksom[c];
val *= scale_mul[c];
rawData[row][3 * col + c] = (val);
const float val = max(0.f, rawData[row][3 * col + c] - cblacksom[c]) * scale_mul[c];
rawData[row][3 * col + c] = val;
tmpchmax[c] = max(tmpchmax[c], val);
}
}