summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-05-11 01:20:26 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-05-11 22:37:02 +0000
commit3c58aa0bf51c64eb126be165e7478e70fbb68043 (patch)
tree4d38c784dbf0c30185e9518c2c91e5f844cde32c /core
parenta5085d45e8288a7ed7af24fc9134d07cbc56e9dc (diff)
downloadpdfium-3c58aa0bf51c64eb126be165e7478e70fbb68043.tar.xz
Use clamp() in a couple more places.
Change-Id: I9b7a1c101e3c73d0270f9216225e5a13d9937b97 Reviewed-on: https://pdfium-review.googlesource.com/5332 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core')
-rw-r--r--core/fpdfapi/render/cpdf_dibsource.cpp3
-rw-r--r--core/fxge/dib/cfx_imagetransformer.cpp2
2 files changed, 2 insertions, 3 deletions
diff --git a/core/fpdfapi/render/cpdf_dibsource.cpp b/core/fpdfapi/render/cpdf_dibsource.cpp
index c2156a1555..f6009674c5 100644
--- a/core/fpdfapi/render/cpdf_dibsource.cpp
+++ b/core/fpdfapi/render/cpdf_dibsource.cpp
@@ -1399,8 +1399,7 @@ void CPDF_DIBSource::DownSampleScanline32Bit(int orig_Bpp,
m_pCompData[j].m_DecodeStep * component_value) *
255.0f +
0.5f);
- extracted_components[j] =
- color_value > 255 ? 255 : (color_value < 0 ? 0 : color_value);
+ extracted_components[j] = pdfium::clamp(color_value, 0, 255);
}
m_pColorSpace->TranslateImageLine(color, extracted_components, 1, 0,
0, bTransMask);
diff --git a/core/fxge/dib/cfx_imagetransformer.cpp b/core/fxge/dib/cfx_imagetransformer.cpp
index 4b5fe0b0e0..11f5f56ecb 100644
--- a/core/fxge/dib/cfx_imagetransformer.cpp
+++ b/core/fxge/dib/cfx_imagetransformer.cpp
@@ -57,7 +57,7 @@ uint8_t bicubic_interpol(const uint8_t* buf,
s_result += a_result * v_w[i];
}
s_result >>= 16;
- return (uint8_t)(s_result < 0 ? 0 : s_result > 255 ? 255 : s_result);
+ return static_cast<uint8_t>(pdfium::clamp(s_result, 0, 255));
}
void bicubic_get_pos_weight(int pos_pixel[],