| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkCommandLineFlags.h" | 9 #include "SkCommandLineFlags.h" |
| 10 #include "SkData.h" | 10 #include "SkData.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 int tool_main(int argc, char** argv); | 35 int tool_main(int argc, char** argv); |
| 36 int tool_main(int argc, char** argv) { | 36 int tool_main(int argc, char** argv) { |
| 37 SkCommandLineFlags::SetUsage("Print out a row or column of an image."); | 37 SkCommandLineFlags::SetUsage("Print out a row or column of an image."); |
| 38 SkCommandLineFlags::Parse(argc, argv); | 38 SkCommandLineFlags::Parse(argc, argv); |
| 39 | 39 |
| 40 if (FLAGS_rgb > 3 || FLAGS_rgb < 0) { | 40 if (FLAGS_rgb > 3 || FLAGS_rgb < 0) { |
| 41 if (!FLAGS_quiet) { | 41 if (!FLAGS_quiet) { |
| 42 SkDebugf("Channel (--rgb) must be between 0 and 3 (inclusive) - valu
e is %d.\n", | 42 SkDebugf("Channel (--rgb) must be between 0 and 3 (inclusive) - valu
e is %d.\n", |
| 43 FLAGS_rgb); | 43 FLAGS_rgb); |
| 44 } | 44 } |
| 45 return kError; | 45 return kError; |
| 46 } | 46 } |
| 47 | 47 |
| 48 if (FLAGS_row >= 0 && FLAGS_column >= 0) { | 48 if (FLAGS_row >= 0 && FLAGS_column >= 0) { |
| 49 if (!FLAGS_quiet) { | 49 if (!FLAGS_quiet) { |
| 50 SkDebugf("Only one of '-c' or '-r' can be specified at at time.\n"); | 50 SkDebugf("Only one of '-c' or '-r' can be specified at at time.\n"); |
| 51 } | 51 } |
| 52 return kError; | 52 return kError; |
| 53 } | 53 } |
| 54 | 54 |
| 55 if (FLAGS_row < 0 && FLAGS_column < 0) { | 55 if (FLAGS_row < 0 && FLAGS_column < 0) { |
| 56 if (!FLAGS_quiet) { | 56 if (!FLAGS_quiet) { |
| 57 SkDebugf("At least one of '-c' or '-r' need to be specified.\n"); | 57 SkDebugf("At least one of '-c' or '-r' need to be specified.\n"); |
| 58 } | 58 } |
| 59 return kError; | 59 return kError; |
| 60 } | 60 } |
| 61 | 61 |
| 62 sk_sp<SkData> data(SkData::MakeFromFileName(FLAGS_image[0])); | 62 sk_sp<SkData> data(SkData::MakeFromFileName(FLAGS_image[0])); |
| 63 if (nullptr == data) { | 63 if (nullptr == data) { |
| 64 if (!FLAGS_quiet) { | 64 if (!FLAGS_quiet) { |
| 65 SkDebugf("Couldn't open file: %s\n", FLAGS_image[0]); | 65 SkDebugf("Couldn't open file: %s\n", FLAGS_image[0]); |
| 66 } | 66 } |
| 67 return kError; | 67 return kError; |
| 68 } | 68 } |
| 69 | 69 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 SkDebugf(", %d", ((c) >> (FLAGS_rgb*8)) & 0xFF); | 121 SkDebugf(", %d", ((c) >> (FLAGS_rgb*8)) & 0xFF); |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 } else { | 124 } else { |
| 125 for (int y = top; y <= bottom; ++y) { | 125 for (int y = top; y <= bottom; ++y) { |
| 126 for (int x = left; x <= right; ++x) { | 126 for (int x = left; x <= right; ++x) { |
| 127 SkColor c = bitmap.getColor(x, y); | 127 SkColor c = bitmap.getColor(x, y); |
| 128 | 128 |
| 129 SkDebugf(", %d", ((c) >> (FLAGS_rgb*8)) & 0xFF); | 129 SkDebugf(", %d", ((c) >> (FLAGS_rgb*8)) & 0xFF); |
| 130 } | 130 } |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 | 133 |
| 134 SkDebugf("\n"); | 134 SkDebugf("\n"); |
| 135 | 135 |
| 136 return kSuccess; | 136 return kSuccess; |
| 137 } | 137 } |
| 138 | 138 |
| 139 #if !defined SK_BUILD_FOR_IOS | 139 #if !defined SK_BUILD_FOR_IOS |
| 140 int main(int argc, char * const argv[]) { | 140 int main(int argc, char * const argv[]) { |
| 141 return tool_main(argc, (char**) argv); | 141 return tool_main(argc, (char**) argv); |
| 142 } | 142 } |
| 143 #endif | 143 #endif |
| OLD | NEW |