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 11 matching lines...) Expand all Loading... |
22 __SK_FORCE_IMAGE_DECODER_LINKING; | 22 __SK_FORCE_IMAGE_DECODER_LINKING; |
23 | 23 |
24 DEFINE_string2(readPath, r, "", "Folder(s) and files to decode images. Required.
"); | 24 DEFINE_string2(readPath, r, "", "Folder(s) and files to decode images. Required.
"); |
25 | 25 |
26 struct Format { | 26 struct Format { |
27 SkImageEncoder::Type fType; | 27 SkImageEncoder::Type fType; |
28 SkImageDecoder::Format fFormat; | 28 SkImageDecoder::Format fFormat; |
29 const char* fSuffix; | 29 const char* fSuffix; |
30 }; | 30 }; |
31 | 31 |
| 32 /* |
32 static const Format gFormats[] = { | 33 static const Format gFormats[] = { |
33 { SkImageEncoder::kBMP_Type, SkImageDecoder::kBMP_Format, ".bmp" }, | 34 { SkImageEncoder::kBMP_Type, SkImageDecoder::kBMP_Format, ".bmp" }, |
34 { SkImageEncoder::kGIF_Type, SkImageDecoder::kGIF_Format, ".gif" }, | 35 { SkImageEncoder::kGIF_Type, SkImageDecoder::kGIF_Format, ".gif" }, |
35 { SkImageEncoder::kICO_Type, SkImageDecoder::kICO_Format, ".ico" }, | 36 { SkImageEncoder::kICO_Type, SkImageDecoder::kICO_Format, ".ico" }, |
36 { SkImageEncoder::kJPEG_Type, SkImageDecoder::kJPEG_Format, ".jpg" }, | 37 { SkImageEncoder::kJPEG_Type, SkImageDecoder::kJPEG_Format, ".jpg" }, |
37 { SkImageEncoder::kPNG_Type, SkImageDecoder::kPNG_Format, ".png" }, | 38 { SkImageEncoder::kPNG_Type, SkImageDecoder::kPNG_Format, ".png" }, |
38 { SkImageEncoder::kWBMP_Type, SkImageDecoder::kWBMP_Format, ".wbmp" }, | 39 { SkImageEncoder::kWBMP_Type, SkImageDecoder::kWBMP_Format, ".wbmp" }, |
39 { SkImageEncoder::kWEBP_Type, SkImageDecoder::kWEBP_Format, ".webp" } | 40 { SkImageEncoder::kWEBP_Type, SkImageDecoder::kWEBP_Format, ".webp" } |
40 }; | 41 }; |
| 42 */ |
41 | 43 |
42 static SkISize opaqueSize(const SkBitmap& bm) { | 44 static SkISize opaqueSize(const SkBitmap& bm) { |
43 int width = 1; | 45 int width = 1; |
44 int height = 1; | 46 int height = 1; |
45 for (int y = 0 ; y < bm.height(); y++) { | 47 for (int y = 0 ; y < bm.height(); y++) { |
46 for (int x = 0 ; x < bm.width(); x++) { | 48 for (int x = 0 ; x < bm.width(); x++) { |
47 SkColor color = bm.getColor(x, y); | 49 SkColor color = bm.getColor(x, y); |
48 if (SkColorGetA(color) != 0) { | 50 if (SkColorGetA(color) != 0) { |
49 height = y + 1; | 51 height = y + 1; |
50 width = width > (x + 1) ? width : x + 1; | 52 width = width > (x + 1) ? width : x + 1; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 } | 169 } |
168 | 170 |
169 return 0; | 171 return 0; |
170 } | 172 } |
171 | 173 |
172 #if !defined SK_BUILD_FOR_IOS | 174 #if !defined SK_BUILD_FOR_IOS |
173 int main(int argc, char * const argv[]) { | 175 int main(int argc, char * const argv[]) { |
174 return tool_main(argc, (char**) argv); | 176 return tool_main(argc, (char**) argv); |
175 } | 177 } |
176 #endif | 178 #endif |
OLD | NEW |