Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: tools/imgslice.cpp

Issue 1777753002: Remove uses SkImageDecoder in imgblur and imgslice (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Force linking for image encoders Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/imgblur.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkCommandLineFlags.h" 9 #include "SkCommandLineFlags.h"
9 #include "SkImageDecoder.h" 10 #include "SkData.h"
11 #include "SkImage.h"
10 #include "SkStream.h" 12 #include "SkStream.h"
11 13
12 DEFINE_bool(header, false, "Print an extra row of the min-max values"); 14 DEFINE_bool(header, false, "Print an extra row of the min-max values");
13 DEFINE_string2(label, l, "label", "Label printed as the first value"); 15 DEFINE_string2(label, l, "label", "Label printed as the first value");
14 16
15 DEFINE_string2(image, i, "", "Input image"); 17 DEFINE_string2(image, i, "", "Input image");
16 DEFINE_int32_2(row, r, -1, "Row to extract"); 18 DEFINE_int32_2(row, r, -1, "Row to extract");
17 DEFINE_int32_2(column, c, -1, "Column to extract"); 19 DEFINE_int32_2(column, c, -1, "Column to extract");
18 20
19 DEFINE_int32_2(min, n, 0, "Minimum row/column to extract - inclusive"); 21 DEFINE_int32_2(min, n, 0, "Minimum row/column to extract - inclusive");
(...skipping 30 matching lines...) Expand all
50 return kError; 52 return kError;
51 } 53 }
52 54
53 if (FLAGS_row < 0 && FLAGS_column < 0) { 55 if (FLAGS_row < 0 && FLAGS_column < 0) {
54 if (!FLAGS_quiet) { 56 if (!FLAGS_quiet) {
55 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");
56 } 58 }
57 return kError; 59 return kError;
58 } 60 }
59 61
60 SkFILEStream inputStream(FLAGS_image[0]); 62 SkAutoTUnref<SkData> data(SkData::NewFromFileName(FLAGS_image[0]));
61 if (!inputStream.isValid()) { 63 if (nullptr == data) {
62 if (!FLAGS_quiet) { 64 if (!FLAGS_quiet) {
63 SkDebugf("Couldn't open file: %s\n", FLAGS_image[0]); 65 SkDebugf("Couldn't open file: %s\n", FLAGS_image[0]);
64 } 66 }
65 return kError; 67 return kError;
66 } 68 }
67 69
68 SkAutoTDelete<SkImageDecoder> codec(SkImageDecoder::Factory(&inputStream)); 70 SkAutoTDelete<SkImage> image(SkImage::NewFromEncoded(data));
69 if (!codec) { 71 if (!image) {
70 if (!FLAGS_quiet) { 72 if (!FLAGS_quiet) {
71 SkDebugf("Couldn't create codec for: %s.\n", FLAGS_image[0]); 73 SkDebugf("Couldn't create image for: %s.\n", FLAGS_image[0]);
72 } 74 }
73 return kError; 75 return kError;
74 } 76 }
75 77
76 SkBitmap bitmap; 78 SkBitmap bitmap;
77 79 if (!image->asLegacyBitmap(&bitmap, SkImage::kRW_LegacyBitmapMode)) {
78 inputStream.rewind(); 80 if (!FLAGS_quiet) {
79 codec->decode(&inputStream, &bitmap, kN32_SkColorType, SkImageDecoder::kDeco dePixels_Mode); 81 SkDebugf("Couldn't create bitmap for: %s.\n", FLAGS_image[0]);
82 }
83 return kError;
84 }
80 85
81 int top, bottom, left, right; 86 int top, bottom, left, right;
82 87
83 if (-1 != FLAGS_row) { 88 if (-1 != FLAGS_row) {
84 SkASSERT(-1 == FLAGS_column); 89 SkASSERT(-1 == FLAGS_column);
85 90
86 top = bottom = SkTPin(FLAGS_row, 0, bitmap.height()-1); 91 top = bottom = SkTPin(FLAGS_row, 0, bitmap.height()-1);
87 FLAGS_min = left = SkTPin(FLAGS_min, 0, bitmap.width()-1); 92 FLAGS_min = left = SkTPin(FLAGS_min, 0, bitmap.width()-1);
88 FLAGS_max = right = SkTPin(FLAGS_max, left, bitmap.width()-1); 93 FLAGS_max = right = SkTPin(FLAGS_max, left, bitmap.width()-1);
89 } else { 94 } else {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 SkDebugf("\n"); 134 SkDebugf("\n");
130 135
131 return kSuccess; 136 return kSuccess;
132 } 137 }
133 138
134 #if !defined SK_BUILD_FOR_IOS 139 #if !defined SK_BUILD_FOR_IOS
135 int main(int argc, char * const argv[]) { 140 int main(int argc, char * const argv[]) {
136 return tool_main(argc, (char**) argv); 141 return tool_main(argc, (char**) argv);
137 } 142 }
138 #endif 143 #endif
OLDNEW
« no previous file with comments | « tools/imgblur.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698