diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-06-14 18:58:40 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-06-14 18:58:40 +0000 |
commit | 1bdf7fe8f66e46b595451d888f57736caee7f4f2 (patch) | |
tree | ad1a77f5079cda09cec175b6d06923254e0e9cff /tools/pinspect.cpp | |
parent | b8a5c618d2e18d71707ae4dcafbe5153d7ff427f (diff) |
tools/pinspect: quick tool to inspeact the header (and rough validity) of 1 or more picture files
Review URL: https://codereview.appspot.com/6295085
git-svn-id: http://skia.googlecode.com/svn/trunk@4258 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tools/pinspect.cpp')
-rw-r--r-- | tools/pinspect.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tools/pinspect.cpp b/tools/pinspect.cpp new file mode 100644 index 0000000000..0105734bfe --- /dev/null +++ b/tools/pinspect.cpp @@ -0,0 +1,50 @@ +/* + * Copyright 2012 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + + +#include "SkBitmap.h" +#include "SkCanvas.h" +#include "SkOSFile.h" +#include "SkPicture.h" +#include "SkStream.h" +#include "SkString.h" + +static void inspect(const char path[]) { + SkFILEStream stream(path); + if (!stream.isValid()) { + printf("-- Can't open '%s'\n", path); + return; + } + + printf("Opening '%s'...\n", path); + + { + int32_t header[3]; + if (stream.read(header, sizeof(header)) != sizeof(header)) { + printf("-- Failed to read header (12 bytes)\n"); + return; + } + printf("version:%d width:%d height:%d\n", header[0], header[1], header[2]); + } + + stream.rewind(); + SkPicture pic(&stream); + printf("picture size:[%d %d]\n", pic.width(), pic.height()); +} + +int main(int argc, char* const argv[]) { + if (argc < 2) { + printf("Usage: pinspect filename [filename ...]\n"); + } + for (int i = 1; i < argc; ++i) { + inspect(argv[i]); + if (i < argc - 1) { + printf("\n"); + } + } + return 0; +} |