OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
10 #include "SkCommandLineFlags.h" | 10 #include "SkCommandLineFlags.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 { SkImageEncoder::kJPEG_Type, SkImageDecoder::kJPEG_Format, ".jpg" }, | 36 { SkImageEncoder::kJPEG_Type, SkImageDecoder::kJPEG_Format, ".jpg" }, |
37 { SkImageEncoder::kPNG_Type, SkImageDecoder::kPNG_Format, ".png" }, | 37 { SkImageEncoder::kPNG_Type, SkImageDecoder::kPNG_Format, ".png" }, |
38 { SkImageEncoder::kWBMP_Type, SkImageDecoder::kWBMP_Format, ".wbmp" }, | 38 { SkImageEncoder::kWBMP_Type, SkImageDecoder::kWBMP_Format, ".wbmp" }, |
39 { SkImageEncoder::kWEBP_Type, SkImageDecoder::kWEBP_Format, ".webp" } | 39 { SkImageEncoder::kWEBP_Type, SkImageDecoder::kWEBP_Format, ".webp" } |
40 }; | 40 }; |
41 | 41 |
42 SkISize opaqueSize(const SkBitmap& bm) { | 42 SkISize opaqueSize(const SkBitmap& bm) { |
43 int width = 1; | 43 int width = 1; |
44 int height = 1; | 44 int height = 1; |
45 for (int y = 0 ; y < bm.height(); y++) { | 45 for (int y = 0 ; y < bm.height(); y++) { |
46 for (int x = 0 ; x < bm.height(); x++) { | 46 for (int x = 0 ; x < bm.width(); x++) { |
47 SkColor color = bm.getColor(x, y); | 47 SkColor color = bm.getColor(x, y); |
48 if (SkColorGetA(color) != 0) { | 48 if (SkColorGetA(color) != 0) { |
49 height = y + 1; | 49 height = y + 1; |
50 width = width > (x + 1) ? width : x + 1; | 50 width = width > (x + 1) ? width : x + 1; |
51 } | 51 } |
52 } | 52 } |
53 } | 53 } |
54 | 54 |
55 return SkISize::Make(width, height); | 55 return SkISize::Make(width, height); |
56 } | 56 } |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 } | 167 } |
168 | 168 |
169 return 0; | 169 return 0; |
170 } | 170 } |
171 | 171 |
172 #if !defined SK_BUILD_FOR_IOS | 172 #if !defined SK_BUILD_FOR_IOS |
173 int main(int argc, char * const argv[]) { | 173 int main(int argc, char * const argv[]) { |
174 return tool_main(argc, (char**) argv); | 174 return tool_main(argc, (char**) argv); |
175 } | 175 } |
176 #endif | 176 #endif |
OLD | NEW |