| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <fstream> | 8 #include <fstream> |
| 9 #include <iostream> | 9 #include <iostream> |
| 10 #include <iterator> | 10 #include <iterator> |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 // The image will be rotated if |width_in_pixels| is greater than | 363 // The image will be rotated if |width_in_pixels| is greater than |
| 364 // |height_in_pixels|. This is because the page will be rotated to fit | 364 // |height_in_pixels|. This is because the page will be rotated to fit |
| 365 // within a piece of paper. Therefore, |width_in_pixels| and | 365 // within a piece of paper. Therefore, |width_in_pixels| and |
| 366 // |height_in_pixels| have to be swapped or else they won't reflect the | 366 // |height_in_pixels| have to be swapped or else they won't reflect the |
| 367 // dimensions of the rotated page. | 367 // dimensions of the rotated page. |
| 368 if (width_in_pixels > height_in_pixels) | 368 if (width_in_pixels > height_in_pixels) |
| 369 std::swap(width_in_pixels, height_in_pixels); | 369 std::swap(width_in_pixels, height_in_pixels); |
| 370 | 370 |
| 371 total_height_in_pixels += height_in_pixels; | 371 total_height_in_pixels += height_in_pixels; |
| 372 gfx::Rect rect(width_in_pixels, height_in_pixels); | 372 gfx::Rect rect(width_in_pixels, height_in_pixels); |
| 373 PdfRenderSettings settings(rect, kDpi, true); | 373 PdfRenderSettings settings(rect, kDpi, true, |
| 374 PdfRenderSettings::Mode::NORMAL); |
| 374 | 375 |
| 375 int int_max = std::numeric_limits<int>::max(); | 376 int int_max = std::numeric_limits<int>::max(); |
| 376 if (settings.area.width() > int_max / kColorChannels || | 377 if (settings.area.width() > int_max / kColorChannels || |
| 377 settings.area.height() > | 378 settings.area.height() > |
| 378 int_max / (kColorChannels * settings.area.width())) { | 379 int_max / (kColorChannels * settings.area.width())) { |
| 379 FAIL() << "The dimensions of the image are too large." | 380 FAIL() << "The dimensions of the image are too large." |
| 380 << "Decrease the DPI or the dimensions of the image."; | 381 << "Decrease the DPI or the dimensions of the image."; |
| 381 } | 382 } |
| 382 | 383 |
| 383 std::vector<uint8_t> page_bitmap_data(kColorChannels * | 384 std::vector<uint8_t> page_bitmap_data(kColorChannels * |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 // waiting for this message and start waiting for the image data. | 631 // waiting for this message and start waiting for the image data. |
| 631 std::cout << "#EOF\n"; | 632 std::cout << "#EOF\n"; |
| 632 std::cout.flush(); | 633 std::cout.flush(); |
| 633 | 634 |
| 634 SendPng(); | 635 SendPng(); |
| 635 Reset(); | 636 Reset(); |
| 636 } | 637 } |
| 637 } | 638 } |
| 638 | 639 |
| 639 } // namespace printing | 640 } // namespace printing |
| OLD | NEW |