OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 "Resources.h" | 8 #include "Resources.h" |
9 | 9 |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 SkBitmap gamut; | 134 SkBitmap gamut; |
135 if (!GetResourceAsBitmap("gamut.png", &gamut)) { | 135 if (!GetResourceAsBitmap("gamut.png", &gamut)) { |
136 SkDebugf("Program failure.\n"); | 136 SkDebugf("Program failure.\n"); |
137 return -1; | 137 return -1; |
138 } | 138 } |
139 SkCanvas canvas(gamut); | 139 SkCanvas canvas(gamut); |
140 | 140 |
141 // Draw the sRGB gamut if requested. | 141 // Draw the sRGB gamut if requested. |
142 if (FLAGS_sRGB) { | 142 if (FLAGS_sRGB) { |
143 sk_sp<SkColorSpace> sRGBSpace = SkColorSpace::NewNamed(SkColorSpace::kSR
GB_Named); | 143 sk_sp<SkColorSpace> sRGBSpace = SkColorSpace::NewNamed(SkColorSpace::kSR
GB_Named); |
144 draw_gamut(&canvas, as_CSB(sRGBSpace)->toXYZD50(), "sRGB", 0xFFFF9394, f
alse); | 144 const SkMatrix44* mat = as_CSB(sRGBSpace)->requestToXYZD50(); |
| 145 SkASSERT(mat); |
| 146 draw_gamut(&canvas, *mat, "sRGB", 0xFFFF9394, false); |
145 } | 147 } |
146 | 148 |
147 // Draw the Adobe RGB gamut if requested. | 149 // Draw the Adobe RGB gamut if requested. |
148 if (FLAGS_adobeRGB) { | 150 if (FLAGS_adobeRGB) { |
149 sk_sp<SkColorSpace> adobeRGBSpace = SkColorSpace::NewNamed(SkColorSpace:
:kAdobeRGB_Named); | 151 sk_sp<SkColorSpace> adobeRGBSpace = SkColorSpace::NewNamed(SkColorSpace:
:kAdobeRGB_Named); |
150 draw_gamut(&canvas, as_CSB(adobeRGBSpace)->toXYZD50(), "Adobe RGB", 0xFF
31a9e1, false); | 152 const SkMatrix44* mat = as_CSB(adobeRGBSpace)->requestToXYZD50(); |
| 153 SkASSERT(mat); |
| 154 draw_gamut(&canvas, *mat, "Adobe RGB", 0xFF31a9e1, false); |
151 } | 155 } |
152 | 156 |
153 // Draw gamut for the input image. | 157 // Draw gamut for the input image. |
154 sk_sp<SkColorSpace> colorSpace = sk_ref_sp(codec->getInfo().colorSpace()); | 158 sk_sp<SkColorSpace> colorSpace = sk_ref_sp(codec->getInfo().colorSpace()); |
155 if (!colorSpace) { | 159 if (!colorSpace) { |
156 SkDebugf("Image had no embedded color space information. Defaulting to
sRGB.\n"); | 160 SkDebugf("Image had no embedded color space information. Defaulting to
sRGB.\n"); |
157 colorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); | 161 colorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); |
158 } | 162 } |
159 draw_gamut(&canvas, as_CSB(colorSpace)->toXYZD50(), input, 0xFF000000, true)
; | 163 const SkMatrix44* mat = as_CSB(colorSpace)->requestToXYZD50(); |
| 164 SkASSERT(mat); |
| 165 draw_gamut(&canvas, *mat, input, 0xFF000000, true); |
160 | 166 |
161 // Finally, encode the result to the output file. | 167 // Finally, encode the result to the output file. |
162 sk_sp<SkData> out(SkImageEncoder::EncodeData(gamut, SkImageEncoder::kPNG_Typ
e, 100)); | 168 sk_sp<SkData> out(SkImageEncoder::EncodeData(gamut, SkImageEncoder::kPNG_Typ
e, 100)); |
163 if (!out) { | 169 if (!out) { |
164 SkDebugf("Failed to encode gamut output.\n"); | 170 SkDebugf("Failed to encode gamut output.\n"); |
165 return -1; | 171 return -1; |
166 } | 172 } |
167 SkFILEWStream stream(output); | 173 SkFILEWStream stream(output); |
168 bool result = stream.write(out->data(), out->size()); | 174 bool result = stream.write(out->data(), out->size()); |
169 if (!result) { | 175 if (!result) { |
(...skipping 22 matching lines...) Expand all Loading... |
192 SkFILEWStream bitmapStream(FLAGS_uncorrected[0]); | 198 SkFILEWStream bitmapStream(FLAGS_uncorrected[0]); |
193 result = bitmapStream.write(out->data(), out->size()); | 199 result = bitmapStream.write(out->data(), out->size()); |
194 if (!result) { | 200 if (!result) { |
195 SkDebugf("Failed to write uncorrected image output.\n"); | 201 SkDebugf("Failed to write uncorrected image output.\n"); |
196 return -1; | 202 return -1; |
197 } | 203 } |
198 } | 204 } |
199 | 205 |
200 return 0; | 206 return 0; |
201 } | 207 } |
OLD | NEW |