OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkGraphics.h" | 10 #include "SkGraphics.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 { | 33 { |
34 int32_t header[3]; | 34 int32_t header[3]; |
35 if (stream.read(header, sizeof(header)) != sizeof(header)) { | 35 if (stream.read(header, sizeof(header)) != sizeof(header)) { |
36 printf("-- Failed to read header (12 bytes)\n"); | 36 printf("-- Failed to read header (12 bytes)\n"); |
37 return NULL; | 37 return NULL; |
38 } | 38 } |
39 printf("version:%d width:%d height:%d\n", header[0], header[1], header[2
]); | 39 printf("version:%d width:%d height:%d\n", header[0], header[1], header[2
]); |
40 } | 40 } |
41 | 41 |
42 stream.rewind(); | 42 stream.rewind(); |
43 bool success = false; | 43 SkPicture* pic = SkPicture::CreateFromStream(&stream, &lazy_decode_bitmap); |
44 SkPicture* pic = SkNEW_ARGS(SkPicture, (&stream, &success, &lazy_decode_bitm
ap)); | 44 if (NULL == pic) { |
45 if (!success) { | |
46 SkDebugf("Could not create SkPicture: %s\n", path); | 45 SkDebugf("Could not create SkPicture: %s\n", path); |
47 return pic; | 46 return NULL; |
48 } | 47 } |
49 printf("picture size:[%d %d]\n", pic->width(), pic->height()); | 48 printf("picture size:[%d %d]\n", pic->width(), pic->height()); |
50 return pic; | 49 return pic; |
51 } | 50 } |
52 | 51 |
53 static void dumpOps(SkPicture* pic) { | 52 static void dumpOps(SkPicture* pic) { |
54 #ifdef SK_DEVELOPER | 53 #ifdef SK_DEVELOPER |
55 SkDebugfDumper dumper; | 54 SkDebugfDumper dumper; |
56 SkDumpCanvas canvas(&dumper); | 55 SkDumpCanvas canvas(&dumper); |
57 canvas.drawPicture(*pic); | 56 canvas.drawPicture(*pic); |
(...skipping 28 matching lines...) Expand all Loading... |
86 } | 85 } |
87 } | 86 } |
88 return 0; | 87 return 0; |
89 } | 88 } |
90 | 89 |
91 #if !defined SK_BUILD_FOR_IOS | 90 #if !defined SK_BUILD_FOR_IOS |
92 int main(int argc, char * const argv[]) { | 91 int main(int argc, char * const argv[]) { |
93 return tool_main(argc, (char**) argv); | 92 return tool_main(argc, (char**) argv); |
94 } | 93 } |
95 #endif | 94 #endif |
OLD | NEW |