OLD | NEW |
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 Loading... |
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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 } | 619 } |
619 | 620 |
620 FPDF_DestroyLibrary(); | 621 FPDF_DestroyLibrary(); |
621 #ifdef PDF_ENABLE_V8 | 622 #ifdef PDF_ENABLE_V8 |
622 v8::V8::ShutdownPlatform(); | 623 v8::V8::ShutdownPlatform(); |
623 delete platform; | 624 delete platform; |
624 #endif // PDF_ENABLE_V8 | 625 #endif // PDF_ENABLE_V8 |
625 | 626 |
626 return 0; | 627 return 0; |
627 } | 628 } |
OLD | NEW |