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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/imgblur.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/imgslice.cpp
diff --git a/tools/imgslice.cpp b/tools/imgslice.cpp
index e9e3832cd4155f9b8fd6dc9d6d5e4c9108626d12..8128f77dd43d1e8072c19fa64c4d2d3002f2eae5 100644
--- a/tools/imgslice.cpp
+++ b/tools/imgslice.cpp
@@ -5,8 +5,10 @@
* found in the LICENSE file.
*/
+#include "SkBitmap.h"
#include "SkCommandLineFlags.h"
-#include "SkImageDecoder.h"
+#include "SkData.h"
+#include "SkImage.h"
#include "SkStream.h"
DEFINE_bool(header, false, "Print an extra row of the min-max values");
@@ -57,26 +59,29 @@ int tool_main(int argc, char** argv) {
return kError;
}
- SkFILEStream inputStream(FLAGS_image[0]);
- if (!inputStream.isValid()) {
+ SkAutoTUnref<SkData> data(SkData::NewFromFileName(FLAGS_image[0]));
+ if (nullptr == data) {
if (!FLAGS_quiet) {
SkDebugf("Couldn't open file: %s\n", FLAGS_image[0]);
}
return kError;
}
- SkAutoTDelete<SkImageDecoder> codec(SkImageDecoder::Factory(&inputStream));
- if (!codec) {
+ SkAutoTDelete<SkImage> image(SkImage::NewFromEncoded(data));
+ if (!image) {
if (!FLAGS_quiet) {
- SkDebugf("Couldn't create codec for: %s.\n", FLAGS_image[0]);
+ SkDebugf("Couldn't create image for: %s.\n", FLAGS_image[0]);
}
return kError;
}
SkBitmap bitmap;
-
- inputStream.rewind();
- codec->decode(&inputStream, &bitmap, kN32_SkColorType, SkImageDecoder::kDecodePixels_Mode);
+ if (!image->asLegacyBitmap(&bitmap, SkImage::kRW_LegacyBitmapMode)) {
+ if (!FLAGS_quiet) {
+ SkDebugf("Couldn't create bitmap for: %s.\n", FLAGS_image[0]);
+ }
+ return kError;
+ }
int top, bottom, left, right;
« 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