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 "picture_utils.h" | 8 #include "picture_utils.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 48 |
49 void setup_bitmap(SkBitmap* bitmap, int width, int height) { | 49 void setup_bitmap(SkBitmap* bitmap, int width, int height) { |
50 bitmap->allocN32Pixels(width, height); | 50 bitmap->allocN32Pixels(width, height); |
51 bitmap->eraseColor(SK_ColorTRANSPARENT); | 51 bitmap->eraseColor(SK_ColorTRANSPARENT); |
52 } | 52 } |
53 | 53 |
54 bool write_bitmap_to_disk(const SkBitmap& bm, const SkString& dirPath, | 54 bool write_bitmap_to_disk(const SkBitmap& bm, const SkString& dirPath, |
55 const char *subdirOrNull, const SkString& baseName
) { | 55 const char *subdirOrNull, const SkString& baseName
) { |
56 SkString partialPath; | 56 SkString partialPath; |
57 if (subdirOrNull) { | 57 if (subdirOrNull) { |
58 partialPath = SkOSPath::SkPathJoin(dirPath.c_str(), subdirOrNull); | 58 partialPath = SkOSPath::Join(dirPath.c_str(), subdirOrNull); |
59 sk_mkdir(partialPath.c_str()); | 59 sk_mkdir(partialPath.c_str()); |
60 } else { | 60 } else { |
61 partialPath.set(dirPath); | 61 partialPath.set(dirPath); |
62 } | 62 } |
63 SkString fullPath = SkOSPath::SkPathJoin(partialPath.c_str(), baseName.c
_str()); | 63 SkString fullPath = SkOSPath::Join(partialPath.c_str(), baseName.c_str()
); |
64 if (SkImageEncoder::EncodeFile(fullPath.c_str(), bm, SkImageEncoder::kPN
G_Type, 100)) { | 64 if (SkImageEncoder::EncodeFile(fullPath.c_str(), bm, SkImageEncoder::kPN
G_Type, 100)) { |
65 return true; | 65 return true; |
66 } else { | 66 } else { |
67 SkDebugf("Failed to write the bitmap to %s.\n", fullPath.c_str()); | 67 SkDebugf("Failed to write the bitmap to %s.\n", fullPath.c_str()); |
68 return false; | 68 return false; |
69 } | 69 } |
70 } | 70 } |
71 | 71 |
72 } // namespace sk_tools | 72 } // namespace sk_tools |
OLD | NEW |