diff options
author | Jun Fang <jun_fang@foxitsoftware.com> | 2015-12-31 22:33:28 +0800 |
---|---|---|
committer | Jun Fang <jun_fang@foxitsoftware.com> | 2015-12-31 22:33:28 +0800 |
commit | 84f6a5616be0a1988d361a4b54eb83fff8b8c59f (patch) | |
tree | 3dc0c4d5fa2de92da00b0521438013eb0271f88b | |
parent | 8be8a4452a947ce125dd1feea00cc9fd23714ec6 (diff) | |
download | pdfium-84f6a5616be0a1988d361a4b54eb83fff8b8c59f.tar.xz |
Fix a partial rendering problem
BUG=pdfium:336
R=thestig@chromium.org
Review URL: https://codereview.chromium.org/1555773003 .
-rw-r--r-- | samples/pdfium_test.cc | 9 | ||||
-rw-r--r-- | testing/embedder_test.cpp | 7 |
2 files changed, 10 insertions, 6 deletions
diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc index 1b3d82659c..89430f6dfd 100644 --- a/samples/pdfium_test.cc +++ b/samples/pdfium_test.cc @@ -15,6 +15,7 @@ #include "image_diff_png.h" #include "public/fpdf_dataavail.h" +#include "public/fpdf_edit.h" #include "public/fpdf_ext.h" #include "public/fpdf_formfill.h" #include "public/fpdf_text.h" @@ -350,14 +351,14 @@ bool RenderPage(const std::string& name, } int width = static_cast<int>(FPDF_GetPageWidth(page) * scale); int height = static_cast<int>(FPDF_GetPageHeight(page) * scale); - - FPDF_BITMAP bitmap = FPDFBitmap_Create(width, height, 0); + int alpha = FPDFPage_HasTransparency(page) ? 1 : 0; + FPDF_BITMAP bitmap = FPDFBitmap_Create(width, height, alpha); if (!bitmap) { fprintf(stderr, "Page was too large to be rendered.\n"); return false; } - - FPDFBitmap_FillRect(bitmap, 0, 0, width, height, 0xFFFFFFFF); + FPDF_DWORD fill_color = alpha ? 0x00000000 : 0xFFFFFFFF; + FPDFBitmap_FillRect(bitmap, 0, 0, width, height, fill_color); FPDF_RenderPageBitmap(bitmap, page, 0, 0, width, height, 0, 0); FPDF_FFLDraw(form, bitmap, page, 0, 0, width, height, 0, 0); diff --git a/testing/embedder_test.cpp b/testing/embedder_test.cpp index d4ce7eba5a..33c72201a1 100644 --- a/testing/embedder_test.cpp +++ b/testing/embedder_test.cpp @@ -12,6 +12,7 @@ #include <vector> #include "public/fpdf_dataavail.h" +#include "public/fpdf_edit.h" #include "public/fpdf_text.h" #include "public/fpdfview.h" #include "testing/gmock/include/gmock/gmock.h" @@ -213,8 +214,10 @@ FPDF_PAGE EmbedderTest::LoadAndCachePage(int page_number) { FPDF_BITMAP EmbedderTest::RenderPage(FPDF_PAGE page) { int width = static_cast<int>(FPDF_GetPageWidth(page)); int height = static_cast<int>(FPDF_GetPageHeight(page)); - FPDF_BITMAP bitmap = FPDFBitmap_Create(width, height, 0); - FPDFBitmap_FillRect(bitmap, 0, 0, width, height, 0xFFFFFFFF); + int alpha = FPDFPage_HasTransparency(page) ? 1 : 0; + FPDF_BITMAP bitmap = FPDFBitmap_Create(width, height, alpha); + FPDF_DWORD fill_color = alpha ? 0x00000000 : 0xFFFFFFFF; + FPDFBitmap_FillRect(bitmap, 0, 0, width, height, fill_color); FPDF_RenderPageBitmap(bitmap, page, 0, 0, width, height, 0, 0); FPDF_FFLDraw(form_handle_, bitmap, page, 0, 0, width, height, 0, 0); return bitmap; |