| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include <stdio.h> | 8 #include <stdio.h> |
| 9 | 9 |
| 10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 static bool to_png(SkWStream* o, const SkBitmap& bm) { | 42 static bool to_png(SkWStream* o, const SkBitmap& bm) { |
| 43 return SkImageEncoder::EncodeStream(o, bm, SkImageEncoder::kPNG_Type, 100); | 43 return SkImageEncoder::EncodeStream(o, bm, SkImageEncoder::kPNG_Type, 100); |
| 44 } | 44 } |
| 45 | 45 |
| 46 // Note: I could implement this using only MacOS|CG API calls, but | 46 // Note: I could implement this using only MacOS|CG API calls, but |
| 47 // since most of this is already done in Skia, here it is. | 47 // since most of this is already done in Skia, here it is. |
| 48 int main(int argc, char** argv) { | 48 int main(int argc, char** argv) { |
| 49 SkBitmap bm; | 49 SkBitmap bm; |
| 50 SkAutoTDelete<SkStream> in(open_for_reading(argc > 1 ? argv[1] : NULL)); | 50 SkAutoTDelete<SkStream> in(open_for_reading(argc > 1 ? argv[1] : NULL)); |
| 51 SkAutoTDelete<SkWStream> out(open_for_writing(argc > 2 ? argv[2] : NULL)); | 51 SkAutoTDelete<SkWStream> out(open_for_writing(argc > 2 ? argv[2] : NULL)); |
| 52 if (SkPDFDocumentToBitmap(in.detach(), &bm) && to_png(out, bm)) { | 52 if (SkPDFDocumentToBitmap(in.release(), &bm) && to_png(out, bm)) { |
| 53 return 0; | 53 return 0; |
| 54 } else { | 54 } else { |
| 55 return 1; | 55 return 1; |
| 56 } | 56 } |
| 57 } | 57 } |
| OLD | NEW |