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" | |
19 #include "public/fpdf_ext.h" | 18 #include "public/fpdf_ext.h" |
20 #include "public/fpdf_formfill.h" | 19 #include "public/fpdf_formfill.h" |
21 #include "public/fpdf_text.h" | 20 #include "public/fpdf_text.h" |
22 #include "public/fpdfview.h" | 21 #include "public/fpdfview.h" |
23 #include "testing/test_support.h" | 22 #include "testing/test_support.h" |
24 | 23 |
25 #ifdef PDF_ENABLE_V8 | 24 #ifdef PDF_ENABLE_V8 |
26 #include "v8/include/libplatform/libplatform.h" | 25 #include "v8/include/libplatform/libplatform.h" |
27 #include "v8/include/v8.h" | 26 #include "v8/include/v8.h" |
28 #endif // PDF_ENABLE_V8 | 27 #endif // PDF_ENABLE_V8 |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 FPDF_TEXTPAGE text_page = FPDFText_LoadPage(page); | 343 FPDF_TEXTPAGE text_page = FPDFText_LoadPage(page); |
345 FORM_OnAfterLoadPage(page, form); | 344 FORM_OnAfterLoadPage(page, form); |
346 FORM_DoPageAAction(page, form, FPDFPAGE_AACTION_OPEN); | 345 FORM_DoPageAAction(page, form, FPDFPAGE_AACTION_OPEN); |
347 | 346 |
348 double scale = 1.0; | 347 double scale = 1.0; |
349 if (!options.scale_factor_as_string.empty()) { | 348 if (!options.scale_factor_as_string.empty()) { |
350 std::stringstream(options.scale_factor_as_string) >> scale; | 349 std::stringstream(options.scale_factor_as_string) >> scale; |
351 } | 350 } |
352 int width = static_cast<int>(FPDF_GetPageWidth(page) * scale); | 351 int width = static_cast<int>(FPDF_GetPageWidth(page) * scale); |
353 int height = static_cast<int>(FPDF_GetPageHeight(page) * scale); | 352 int height = static_cast<int>(FPDF_GetPageHeight(page) * scale); |
354 int alpha = FPDFPage_HasTransparency(page) ? 1 : 0; | 353 |
355 FPDF_BITMAP bitmap = FPDFBitmap_Create(width, height, alpha); | 354 FPDF_BITMAP bitmap = FPDFBitmap_Create(width, height, 0); |
356 if (!bitmap) { | 355 if (!bitmap) { |
357 fprintf(stderr, "Page was too large to be rendered.\n"); | 356 fprintf(stderr, "Page was too large to be rendered.\n"); |
358 return false; | 357 return false; |
359 } | 358 } |
360 FPDF_DWORD fill_color = alpha ? 0x00000000 : 0xFFFFFFFF; | 359 |
361 FPDFBitmap_FillRect(bitmap, 0, 0, width, height, fill_color); | 360 FPDFBitmap_FillRect(bitmap, 0, 0, width, height, 0xFFFFFFFF); |
362 FPDF_RenderPageBitmap(bitmap, page, 0, 0, width, height, 0, 0); | 361 FPDF_RenderPageBitmap(bitmap, page, 0, 0, width, height, 0, 0); |
363 | 362 |
364 FPDF_FFLDraw(form, bitmap, page, 0, 0, width, height, 0, 0); | 363 FPDF_FFLDraw(form, bitmap, page, 0, 0, width, height, 0, 0); |
365 int stride = FPDFBitmap_GetStride(bitmap); | 364 int stride = FPDFBitmap_GetStride(bitmap); |
366 const char* buffer = | 365 const char* buffer = |
367 reinterpret_cast<const char*>(FPDFBitmap_GetBuffer(bitmap)); | 366 reinterpret_cast<const char*>(FPDFBitmap_GetBuffer(bitmap)); |
368 | 367 |
369 switch (options.output_format) { | 368 switch (options.output_format) { |
370 #ifdef _WIN32 | 369 #ifdef _WIN32 |
371 case OUTPUT_BMP: | 370 case OUTPUT_BMP: |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 } | 597 } |
599 | 598 |
600 FPDF_DestroyLibrary(); | 599 FPDF_DestroyLibrary(); |
601 #ifdef PDF_ENABLE_V8 | 600 #ifdef PDF_ENABLE_V8 |
602 v8::V8::ShutdownPlatform(); | 601 v8::V8::ShutdownPlatform(); |
603 delete platform; | 602 delete platform; |
604 #endif // PDF_ENABLE_V8 | 603 #endif // PDF_ENABLE_V8 |
605 | 604 |
606 return 0; | 605 return 0; |
607 } | 606 } |
OLD | NEW |