| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkCanvas.h" | 8 #include "SkCanvas.h" |
| 9 #include "SkCommandLineFlags.h" | 9 #include "SkCommandLineFlags.h" |
| 10 #include "SkData.h" | 10 #include "SkData.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info)); | 50 SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info)); |
| 51 SkCanvas* canvas = surface->getCanvas(); | 51 SkCanvas* canvas = surface->getCanvas(); |
| 52 | 52 |
| 53 canvas->drawColor(SK_ColorWHITE); | 53 canvas->drawColor(SK_ColorWHITE); |
| 54 canvas->drawText(text.c_str(), text.size(), | 54 canvas->drawText(text.c_str(), text.size(), |
| 55 SkIntToScalar(w)/2, SkIntToScalar(h)*2/3, | 55 SkIntToScalar(w)/2, SkIntToScalar(h)*2/3, |
| 56 paint); | 56 paint); |
| 57 | 57 |
| 58 SkAutoTUnref<SkImage> image(surface->newImageSnapshot()); | 58 SkAutoTUnref<SkImage> image(surface->newImageSnapshot()); |
| 59 SkAutoDataUnref data(image->encode()); | 59 SkAutoDataUnref data(image->encode()); |
| 60 if (NULL == data.get()) { |
| 61 return -1; |
| 62 } |
| 60 SkFILEWStream stream(path.c_str()); | 63 SkFILEWStream stream(path.c_str()); |
| 61 return stream.write(data->data(), data->size()); | 64 return stream.write(data->data(), data->size()); |
| 62 } | 65 } |
| 63 | 66 |
| 64 #if !defined SK_BUILD_FOR_IOS | 67 #if !defined SK_BUILD_FOR_IOS |
| 65 int main(int argc, char * const argv[]) { | 68 int main(int argc, char * const argv[]) { |
| 66 return tool_main(argc, (char**) argv); | 69 return tool_main(argc, (char**) argv); |
| 67 } | 70 } |
| 68 #endif | 71 #endif |
| OLD | NEW |