Use the correct stride in CFX_SkiaDeviceDriver::GetDIBits().
It is incorrect to assume the bitmaps will have a BPP of 32.
Bug: chromium:1099446
Change-Id: Ibdab7fcfd9e0cd5a485396be3fcbb6f00d162426
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/70933
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp
index e177645..bd166ca 100644
--- a/core/fxge/skia/fx_skia_device.cpp
+++ b/core/fxge/skia/fx_skia_device.cpp
@@ -2355,7 +2355,7 @@
m_pCache->FlushForDraw();
int srcWidth = m_pBitmap->GetWidth();
int srcHeight = m_pBitmap->GetHeight();
- int srcRowBytes = srcWidth * sizeof(uint32_t);
+ size_t srcRowBytes = m_pBitmap->GetPitch();
SkImageInfo srcImageInfo = SkImageInfo::Make(
srcWidth, srcHeight, SkColorType::kN32_SkColorType, kPremul_SkAlphaType);
SkBitmap skSrcBitmap;
@@ -2364,7 +2364,7 @@
ASSERT(dstBuffer);
int dstWidth = pBitmap->GetWidth();
int dstHeight = pBitmap->GetHeight();
- int dstRowBytes = dstWidth * sizeof(uint32_t);
+ size_t dstRowBytes = pBitmap->GetPitch();
SkImageInfo dstImageInfo = SkImageInfo::Make(
dstWidth, dstHeight, Get32BitSkColorType(m_bRgbByteOrder),
kPremul_SkAlphaType);
diff --git a/testing/resources/pixel/bug_1099446.in b/testing/resources/pixel/bug_1099446.in
new file mode 100644
index 0000000..49d6dae
--- /dev/null
+++ b/testing/resources/pixel/bug_1099446.in
@@ -0,0 +1,65 @@
+{{header}}
+{{object 1 0}} <<
+ /Type /Catalog
+ /Pages 2 0 R
+>>
+endobj
+{{object 2 0}} <<
+ /Type /Pages
+ /Count 1
+ /Kids [3 0 R]
+>>
+endobj
+{{object 3 0}} <<
+ /Type /Page
+ /Contents 4 0 R
+ /MediaBox [0 0 200 200]
+ /Resources <<
+ /ExtGState <<
+ /G1 5 0 R
+ >>
+ /Pattern <<
+ /P1 6 0 R
+ >>
+ >>
+>>
+endobj
+{{object 4 0}} <<
+ {{streamlen}}
+>>
+stream
+200 0 m
+0 200 l
+/G1 gs
+/P1 SCN
+/P1 S
+endstream
+endobj
+{{object 5 0}} <<
+ /BM /Diff
+>>
+endobj
+{{object 6 0}} <<
+ /Type /Pattern
+ /PatternType 1
+ /Resources <<
+ /ExtGState <<
+ /G1 5 0 R
+ >>
+ /Pattern <<
+ /P1 6 0 R
+ >>
+ >>
+ {{streamlen}}
+>>
+stream
+200 0 m
+0 200 l
+/G3 gs
+/P1 S
+endstream
+endobj
+{{xref}}
+{{trailer}}
+{{startxref}}
+%%EOF
diff --git a/testing/resources/pixel/bug_1099446_expected.pdf.0.png b/testing/resources/pixel/bug_1099446_expected.pdf.0.png
new file mode 100644
index 0000000..1074bd8
--- /dev/null
+++ b/testing/resources/pixel/bug_1099446_expected.pdf.0.png
Binary files differ