From cfd56852b6375d2b4eea473399231caf7dcdbf36 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Thu, 18 May 2017 00:50:14 -0700 Subject: Fix a situation where images are not properly rendered. This regressed in commit e21fe98. When the image's bpc is a multiple of 8, there exists a colorspace, and there is a Decode parameter, the image data source was incorrectly pointing to a data structure that only contained black pixels. BUG=chromium:718762 Change-Id: I5d3fa739e41726b4ed1ebc16465e17f83fff9f8d Reviewed-on: https://pdfium-review.googlesource.com/5333 Commit-Queue: Lei Zhang Reviewed-by: Tom Sepez --- core/fpdfapi/render/cpdf_dibsource.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'core/fpdfapi/render') diff --git a/core/fpdfapi/render/cpdf_dibsource.cpp b/core/fpdfapi/render/cpdf_dibsource.cpp index f6009674c5..f1c58038e8 100644 --- a/core/fpdfapi/render/cpdf_dibsource.cpp +++ b/core/fpdfapi/render/cpdf_dibsource.cpp @@ -1361,7 +1361,7 @@ void CPDF_DIBSource::DownSampleScanline32Bit(int orig_Bpp, if (src_x == last_src_x) { argb = last_argb; } else { - CFX_FixedBufGrow extracted_components(m_nComponents); + CFX_FixedBufGrow extracted_components(m_nComponents); const uint8_t* pSrcPixel = nullptr; if (m_bpc % 8 != 0) { // No need to check for 32-bit overflow, as |src_x| is bounded by @@ -1388,12 +1388,9 @@ void CPDF_DIBSource::DownSampleScanline32Bit(int orig_Bpp, if (m_pColorSpace) { uint8_t color[4]; const bool bTransMask = TransMask(); - if (m_bDefaultDecode) { - m_pColorSpace->TranslateImageLine(color, pSrcPixel, 1, 0, 0, - bTransMask); - } else { + if (!m_bDefaultDecode) { for (uint32_t j = 0; j < m_nComponents; ++j) { - float component_value = static_cast(extracted_components[j]); + float component_value = static_cast(pSrcPixel[j]); int color_value = static_cast( (m_pCompData[j].m_DecodeMin + m_pCompData[j].m_DecodeStep * component_value) * @@ -1401,9 +1398,10 @@ void CPDF_DIBSource::DownSampleScanline32Bit(int orig_Bpp, 0.5f); extracted_components[j] = pdfium::clamp(color_value, 0, 255); } - m_pColorSpace->TranslateImageLine(color, extracted_components, 1, 0, - 0, bTransMask); } + const uint8_t* pSrc = + m_bDefaultDecode ? pSrcPixel : extracted_components; + m_pColorSpace->TranslateImageLine(color, pSrc, 1, 0, 0, bTransMask); argb = FXARGB_MAKE(0xFF, color[2], color[1], color[0]); } else { argb = FXARGB_MAKE(0xFF, pSrcPixel[2], pSrcPixel[1], pSrcPixel[0]); -- cgit v1.2.3