aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorBrian Osman <brianosman@google.com>2019-01-04 11:03:42 -0500
committerSkia Commit-Bot <skia-commit-bot@chromium.org>2019-01-04 16:43:07 +0000
commit18df87ec8bda0d01999c52fde7c1b7eed663afb5 (patch)
tree941573531a6dd373d8fad137b59a2fff40763c91 /tools
parent6793ad980ab5fa8242f0180fd7f45d6ae8f26345 (diff)
downloadskqp-18df87ec8bda0d01999c52fde7c1b7eed663afb5.tar.gz
Fix bugs and add features to imgcvt
- The dst_profile data needs to live at least as long as the profile. - Support converting jpg sources (where pixmap alpha type is kOpaque). - Add a fallback path that makes the destination profile usable. Bug: skia: Change-Id: I11c2c7213532f4b6ba38afd45dd6a2afddea0c52 Reviewed-on: https://skia-review.googlesource.com/c/181171 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/imgcvt.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/tools/imgcvt.cpp b/tools/imgcvt.cpp
index afc949811b..a1b96e2b63 100644
--- a/tools/imgcvt.cpp
+++ b/tools/imgcvt.cpp
@@ -28,9 +28,10 @@ int main(int argc, char** argv) {
const char* dst_profile_path = argc > 2 ? argv[2] : nullptr;
skcms_ICCProfile dst_profile = *skcms_sRGB_profile();
+ sk_sp<SkData> dst_blob;
if (dst_profile_path) {
- sk_sp<SkData> blob = SkData::MakeFromFileName(dst_profile_path);
- if (!skcms_Parse(blob->data(), blob->size(), &dst_profile)) {
+ dst_blob = SkData::MakeFromFileName(dst_profile_path);
+ if (!skcms_Parse(dst_blob->data(), dst_blob->size(), &dst_profile)) {
SkDebugf("Can't parse %s as an ICC profile.\n", dst_profile_path);
return 1;
}
@@ -90,8 +91,14 @@ int main(int argc, char** argv) {
sk_sp<SkColorSpace> dst_cs = SkColorSpace::Make(dst_profile);
if (!dst_cs) {
- SkDebugf("We can't convert to this destination profile.\n");
- return 1;
+ SkDebugf("We can't convert to this destination profile as-is. Coercing it.\n");
+ if (skcms_MakeUsableAsDestinationWithSingleCurve(&dst_profile)) {
+ dst_cs = SkColorSpace::Make(dst_profile);
+ }
+ if (!dst_cs) {
+ SkDebugf("We can't convert to this destination profile at all.\n");
+ return 1;
+ }
}
{ // transform with skcms
@@ -109,7 +116,7 @@ int main(int argc, char** argv) {
return 1;
}
- if (pixmap.alphaType() != kPremul_SkAlphaType) {
+ if (pixmap.alphaType() == kUnpremul_SkAlphaType) {
SkDebugf("not premul, that's weird.\n");
return 1;
}