OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #ifdef SK_BUILD_FOR_WIN32 | 9 #ifdef SK_BUILD_FOR_WIN32 |
10 #pragma warning(push) | 10 #pragma warning(push) |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 if (!image.is_valid() || image.format() != poppler::image::format_argb32) { | 44 if (!image.is_valid() || image.format() != poppler::image::format_argb32) { |
45 return false; | 45 return false; |
46 } | 46 } |
47 | 47 |
48 int width = image.width(), height = image.height(); | 48 int width = image.width(), height = image.height(); |
49 size_t rowSize = image.bytes_per_row(); | 49 size_t rowSize = image.bytes_per_row(); |
50 char *imgData = image.data(); | 50 char *imgData = image.data(); |
51 | 51 |
52 SkBitmap bitmap; | 52 SkBitmap bitmap; |
53 if (!bitmap.allocPixels(SkImageInfo::MakeN32Premul(width, height))) { | 53 if (!bitmap.tryAllocN32Pixels(width, height)) { |
54 return false; | 54 return false; |
55 } | 55 } |
56 bitmap.eraseColor(SK_ColorWHITE); | 56 bitmap.eraseColor(SK_ColorWHITE); |
57 SkPMColor* bitmapPixels = (SkPMColor*)bitmap.getPixels(); | 57 SkPMColor* bitmapPixels = (SkPMColor*)bitmap.getPixels(); |
58 | 58 |
59 // do pixel-by-pixel copy to deal with RGBA ordering conversions | 59 // do pixel-by-pixel copy to deal with RGBA ordering conversions |
60 for (int y = 0; y < height; y++) { | 60 for (int y = 0; y < height; y++) { |
61 char *rowData = imgData; | 61 char *rowData = imgData; |
62 for (int x = 0; x < width; x++) { | 62 for (int x = 0; x < width; x++) { |
63 uint8_t a = rowData[3]; | 63 uint8_t a = rowData[3]; |
(...skipping 13 matching lines...) Expand all Loading... |
77 | 77 |
78 return true; | 78 return true; |
79 } | 79 } |
80 #endif // SK_BUILD_POPPLER | 80 #endif // SK_BUILD_POPPLER |
81 | 81 |
82 #ifdef SK_BUILD_NATIVE_PDF_RENDERER | 82 #ifdef SK_BUILD_NATIVE_PDF_RENDERER |
83 bool SkNativeRasterizePDF(SkStream* pdf, SkBitmap* output) { | 83 bool SkNativeRasterizePDF(SkStream* pdf, SkBitmap* output) { |
84 return SkPDFNativeRenderToBitmap(pdf, output); | 84 return SkPDFNativeRenderToBitmap(pdf, output); |
85 } | 85 } |
86 #endif // SK_BUILD_NATIVE_PDF_RENDERER | 86 #endif // SK_BUILD_NATIVE_PDF_RENDERER |
OLD | NEW |