aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar Matt Sarett <msarett@google.com>2017-05-01 17:52:56 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-05-02 13:22:20 +0000
commit687cc6c033506c767a960eb57b4d703a76424bfd (patch)
treebe0f83bfa062ea30af4a1386963c3d3ad3e1e0cc /tools
parentab865b088397148ac0a5d6a631f9278303a3dba8 (diff)
colorspaceinfo tool: Add flag to indicate that the input is an icc profile
Bug: skia: Change-Id: Ieb5cff92bae1aa64df5bc7f3a398514fe5b20f77 Reviewed-on: https://skia-review.googlesource.com/14956 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Matt Sarett <msarett@google.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/colorspaceinfo.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/tools/colorspaceinfo.cpp b/tools/colorspaceinfo.cpp
index 91445db27e..4d4d8c0be2 100644
--- a/tools/colorspaceinfo.cpp
+++ b/tools/colorspaceinfo.cpp
@@ -24,8 +24,9 @@
#include <string>
#include <vector>
-DEFINE_string(input, "input.png", "A path to the input image or icc profile.");
+DEFINE_string(input, "input.png", "A path to the input image (or icc profile with --icc).");
DEFINE_string(output, ".", "A path to the output image directory.");
+DEFINE_bool(icc, false, "Indicates that the input is an icc profile.");
DEFINE_bool(sRGB_gamut, false, "Draws the sRGB gamut on the gamut visualization.");
DEFINE_bool(adobeRGB, false, "Draws the Adobe RGB gamut on the gamut visualization.");
DEFINE_bool(sRGB_gamma, false, "Draws the sRGB gamma on all gamma output images.");
@@ -432,8 +433,9 @@ private:
int main(int argc, char** argv) {
SkCommandLineFlags::SetUsage(
- "Usage: colorspaceinfo --input <path to input image or icc profile> "
+ "Usage: colorspaceinfo --input <path to input image (or icc profile with --icc)> "
"--output <directory to output images> "
+ "--icc <indicates that the input is an icc profile>"
"--sRGB_gamut <draw canonical sRGB gamut> "
"--adobeRGB <draw canonical Adobe RGB gamut> "
"--sRGB_gamma <draw sRGB gamma> "
@@ -454,13 +456,14 @@ int main(int argc, char** argv) {
SkDebugf("Cannot find input image.\n");
return -1;
}
- std::unique_ptr<SkCodec> codec(SkCodec::NewFromData(data));
+
+ std::unique_ptr<SkCodec> codec = nullptr;
sk_sp<SkColorSpace> colorSpace = nullptr;
- const bool isImage = (codec != nullptr);
- if (isImage) {
- colorSpace = sk_ref_sp(codec->getInfo().colorSpace());
- } else {
+ if (FLAGS_icc) {
colorSpace = SkColorSpace::MakeICC(data->bytes(), data->size());
+ } else {
+ codec.reset(SkCodec::NewFromData(data));
+ colorSpace = sk_ref_sp(codec->getInfo().colorSpace());
}
if (!colorSpace) {
@@ -611,11 +614,11 @@ int main(int argc, char** argv) {
for (const std::string& filename : outputFilenames) {
SkDebugf("%s\n", filename.c_str());
}
- if (isImage) {
+ if (!FLAGS_icc) {
SkDebugf("%s\n", input);
}
// Also, if requested, decode and reencode the uncorrected input image.
- if (!FLAGS_uncorrected.isEmpty() && isImage) {
+ if (!FLAGS_uncorrected.isEmpty() && !FLAGS_icc) {
SkBitmap bitmap;
int width = codec->getInfo().width();
int height = codec->getInfo().height();