| 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" |
| 11 #include "SkEncodedFormat.h" |
| 11 #include "SkImageEncoder.h" | 12 #include "SkImageEncoder.h" |
| 12 #include "SkOSFile.h" | 13 #include "SkOSFile.h" |
| 13 #include "SkPicture.h" | 14 #include "SkPicture.h" |
| 14 #include "SkStream.h" | 15 #include "SkStream.h" |
| 15 #include "SkString.h" | 16 #include "SkString.h" |
| 16 | 17 |
| 17 namespace sk_tools { | 18 namespace sk_tools { |
| 18 void force_all_opaque(const SkBitmap& bitmap) { | 19 void force_all_opaque(const SkBitmap& bitmap) { |
| 19 SkASSERT(NULL == bitmap.getTexture()); | 20 SkASSERT(NULL == bitmap.getTexture()); |
| 20 SkASSERT(kN32_SkColorType == bitmap.colorType()); | 21 SkASSERT(kN32_SkColorType == bitmap.colorType()); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 bool write_bitmap_to_disk(const SkBitmap& bm, const SkString& dirPath, | 55 bool write_bitmap_to_disk(const SkBitmap& bm, const SkString& dirPath, |
| 55 const char *subdirOrNull, const SkString& baseName
) { | 56 const char *subdirOrNull, const SkString& baseName
) { |
| 56 SkString partialPath; | 57 SkString partialPath; |
| 57 if (subdirOrNull) { | 58 if (subdirOrNull) { |
| 58 partialPath = SkOSPath::Join(dirPath.c_str(), subdirOrNull); | 59 partialPath = SkOSPath::Join(dirPath.c_str(), subdirOrNull); |
| 59 sk_mkdir(partialPath.c_str()); | 60 sk_mkdir(partialPath.c_str()); |
| 60 } else { | 61 } else { |
| 61 partialPath.set(dirPath); | 62 partialPath.set(dirPath); |
| 62 } | 63 } |
| 63 SkString fullPath = SkOSPath::Join(partialPath.c_str(), baseName.c_str()
); | 64 SkString fullPath = SkOSPath::Join(partialPath.c_str(), baseName.c_str()
); |
| 64 if (SkImageEncoder::EncodeFile(fullPath.c_str(), bm, SkImageEncoder::kPN
G_Type, 100)) { | 65 if (SkImageEncoder::EncodeFile(fullPath.c_str(), bm, kPNG_SkEncodedForma
t, 100)) { |
| 65 return true; | 66 return true; |
| 66 } else { | 67 } else { |
| 67 SkDebugf("Failed to write the bitmap to %s.\n", fullPath.c_str()); | 68 SkDebugf("Failed to write the bitmap to %s.\n", fullPath.c_str()); |
| 68 return false; | 69 return false; |
| 69 } | 70 } |
| 70 } | 71 } |
| 71 | 72 |
| 72 } // namespace sk_tools | 73 } // namespace sk_tools |
| OLD | NEW |