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" |
11 #include "SkCGUtils.h" | 11 #include "SkCGUtils.h" |
| 12 #include "SkForceLinking.h" |
12 #include "SkImageEncoder.h" | 13 #include "SkImageEncoder.h" |
13 #include "SkStream.h" | 14 #include "SkStream.h" |
14 | 15 |
| 16 __SK_FORCE_IMAGE_DECODER_LINKING; |
| 17 |
15 class StdOutWStream : public SkWStream { | 18 class StdOutWStream : public SkWStream { |
16 public: | 19 public: |
17 StdOutWStream() : fBytesWritten(0) {} | 20 StdOutWStream() : fBytesWritten(0) {} |
18 bool write(const void* buffer, size_t size) final { | 21 bool write(const void* buffer, size_t size) final { |
19 fBytesWritten += size; | 22 fBytesWritten += size; |
20 return size == fwrite(buffer, 1, size, stdout); | 23 return size == fwrite(buffer, 1, size, stdout); |
21 } | 24 } |
22 size_t bytesWritten() const final { return fBytesWritten; } | 25 size_t bytesWritten() const final { return fBytesWritten; } |
23 | 26 |
24 private: | 27 private: |
(...skipping 23 matching lines...) Expand all Loading... |
48 int main(int argc, char** argv) { | 51 int main(int argc, char** argv) { |
49 SkBitmap bm; | 52 SkBitmap bm; |
50 SkAutoTDelete<SkStream> in(open_for_reading(argc > 1 ? argv[1] : NULL)); | 53 SkAutoTDelete<SkStream> in(open_for_reading(argc > 1 ? argv[1] : NULL)); |
51 SkAutoTDelete<SkWStream> out(open_for_writing(argc > 2 ? argv[2] : NULL)); | 54 SkAutoTDelete<SkWStream> out(open_for_writing(argc > 2 ? argv[2] : NULL)); |
52 if (SkPDFDocumentToBitmap(in.release(), &bm) && to_png(out, bm)) { | 55 if (SkPDFDocumentToBitmap(in.release(), &bm) && to_png(out, bm)) { |
53 return 0; | 56 return 0; |
54 } else { | 57 } else { |
55 return 1; | 58 return 1; |
56 } | 59 } |
57 } | 60 } |
OLD | NEW |