Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: samples/pdfium_test.cc

Issue 1555773003: Fix a partial rendering problem (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | testing/embedder_test.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <limits.h> 5 #include <limits.h>
6 #include <stdio.h> 6 #include <stdio.h>
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include <list> 10 #include <list>
11 #include <sstream> 11 #include <sstream>
12 #include <string> 12 #include <string>
13 #include <utility> 13 #include <utility>
14 #include <vector> 14 #include <vector>
15 15
16 #include "image_diff_png.h" 16 #include "image_diff_png.h"
17 #include "public/fpdf_dataavail.h" 17 #include "public/fpdf_dataavail.h"
18 #include "public/fpdf_edit.h"
18 #include "public/fpdf_ext.h" 19 #include "public/fpdf_ext.h"
19 #include "public/fpdf_formfill.h" 20 #include "public/fpdf_formfill.h"
20 #include "public/fpdf_text.h" 21 #include "public/fpdf_text.h"
21 #include "public/fpdfview.h" 22 #include "public/fpdfview.h"
22 #include "testing/test_support.h" 23 #include "testing/test_support.h"
23 24
24 #ifdef PDF_ENABLE_V8 25 #ifdef PDF_ENABLE_V8
25 #include "v8/include/libplatform/libplatform.h" 26 #include "v8/include/libplatform/libplatform.h"
26 #include "v8/include/v8.h" 27 #include "v8/include/v8.h"
27 #endif // PDF_ENABLE_V8 28 #endif // PDF_ENABLE_V8
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 FPDF_TEXTPAGE text_page = FPDFText_LoadPage(page); 344 FPDF_TEXTPAGE text_page = FPDFText_LoadPage(page);
344 FORM_OnAfterLoadPage(page, form); 345 FORM_OnAfterLoadPage(page, form);
345 FORM_DoPageAAction(page, form, FPDFPAGE_AACTION_OPEN); 346 FORM_DoPageAAction(page, form, FPDFPAGE_AACTION_OPEN);
346 347
347 double scale = 1.0; 348 double scale = 1.0;
348 if (!options.scale_factor_as_string.empty()) { 349 if (!options.scale_factor_as_string.empty()) {
349 std::stringstream(options.scale_factor_as_string) >> scale; 350 std::stringstream(options.scale_factor_as_string) >> scale;
350 } 351 }
351 int width = static_cast<int>(FPDF_GetPageWidth(page) * scale); 352 int width = static_cast<int>(FPDF_GetPageWidth(page) * scale);
352 int height = static_cast<int>(FPDF_GetPageHeight(page) * scale); 353 int height = static_cast<int>(FPDF_GetPageHeight(page) * scale);
353 354 int alpha = FPDFPage_HasTransparency(page) ? 1 : 0;
354 FPDF_BITMAP bitmap = FPDFBitmap_Create(width, height, 0); 355 FPDF_BITMAP bitmap = FPDFBitmap_Create(width, height, alpha);
355 if (!bitmap) { 356 if (!bitmap) {
356 fprintf(stderr, "Page was too large to be rendered.\n"); 357 fprintf(stderr, "Page was too large to be rendered.\n");
357 return false; 358 return false;
358 } 359 }
359 360 FPDF_DWORD fill_color = alpha ? 0x00000000 : 0xFFFFFFFF;
360 FPDFBitmap_FillRect(bitmap, 0, 0, width, height, 0xFFFFFFFF); 361 FPDFBitmap_FillRect(bitmap, 0, 0, width, height, fill_color);
361 FPDF_RenderPageBitmap(bitmap, page, 0, 0, width, height, 0, 0); 362 FPDF_RenderPageBitmap(bitmap, page, 0, 0, width, height, 0, 0);
362 363
363 FPDF_FFLDraw(form, bitmap, page, 0, 0, width, height, 0, 0); 364 FPDF_FFLDraw(form, bitmap, page, 0, 0, width, height, 0, 0);
364 int stride = FPDFBitmap_GetStride(bitmap); 365 int stride = FPDFBitmap_GetStride(bitmap);
365 const char* buffer = 366 const char* buffer =
366 reinterpret_cast<const char*>(FPDFBitmap_GetBuffer(bitmap)); 367 reinterpret_cast<const char*>(FPDFBitmap_GetBuffer(bitmap));
367 368
368 switch (options.output_format) { 369 switch (options.output_format) {
369 #ifdef _WIN32 370 #ifdef _WIN32
370 case OUTPUT_BMP: 371 case OUTPUT_BMP:
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 } 598 }
598 599
599 FPDF_DestroyLibrary(); 600 FPDF_DestroyLibrary();
600 #ifdef PDF_ENABLE_V8 601 #ifdef PDF_ENABLE_V8
601 v8::V8::ShutdownPlatform(); 602 v8::V8::ShutdownPlatform();
602 delete platform; 603 delete platform;
603 #endif // PDF_ENABLE_V8 604 #endif // PDF_ENABLE_V8
604 605
605 return 0; 606 return 0;
606 } 607 }
OLDNEW
« no previous file with comments | « no previous file | testing/embedder_test.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698