23 {
24 const char* source_path = argc > 1 ?
argv[1] :
nullptr;
25 if (!source_path) {
26 SkDebugf(
"Please pass an image or profile to convert"
27 " as the first argument to this program.\n");
28 return 1;
29 }
30
31 const char* dst_profile_path = argc > 2 ?
argv[2] :
nullptr;
34 if (dst_profile_path) {
37 SkDebugf(
"Can't parse %s as an ICC profile.\n", dst_profile_path);
38 return 1;
39 }
40 }
41
43
45 if (
skcms_Parse(blob->data(), blob->size(), &src_profile)) {
46
48 0,0,0,
49 1,1,1,
50
51 1,0,0,
52 0,1,0,
53 0,0,1,
54
55 0,1,1,
56 1,0,1,
57 1,1,0,
58 };
60
64 8)) {
66 return 1;
67 }
68 for (
int i = 0;
i < 8;
i++) {
69 SkDebugf(
"(%g, %g, %g) --> (%+.4f, %+.4f, %+.4f)\n",
72 }
73 return 0;
74 }
75
78 SkDebugf(
"Couldn't decode %s as an SkImage or an ICC profile.\n", source_path);
79 return 1;
80 }
81
84 SkDebugf(
"Converting to raster image failed.\n");
85 return 1;
86 }
87
90 SkDebugf(
"We really should be able to peek raster pixels.\n");
91 return 1;
92 }
93
95 if (!dst_cs) {
96 SkDebugf(
"We can't convert to this destination profile as-is. Coercing it.\n");
99 }
100 if (!dst_cs) {
101 SkDebugf(
"We can't convert to this destination profile at all.\n");
102 return 1;
103 }
104 }
105
106 {
110
115 default:
116 SkDebugf(
"color type %d not yet supported, imgcvt.cpp needs an update.\n",
118 return 1;
119 }
120
122 SkDebugf(
"not premul, that's weird.\n");
123 return 1;
124 }
126
128 SkDebugf(
"not a tight pixmap, need a loop here\n");
129 return 1;
130 }
131
135 SkDebugf(
"skcms_Transform() failed\n");
136 return 1;
137 }
139
141 }
142
143 {
146 SkDebugf(
"couldn't create a surface\n");
147 return 1;
148 }
149
150 surface->writePixels(pixmap, 0,0);
151
153 }
154
155 {
158 SkDebugf(
"couldn't create a surface\n");
159 return 1;
160 }
161
163
165 }
166
167 return 0;
168}
SkColorSpace * sk_srgb_singleton()
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
void toProfile(skcms_ICCProfile *) const
static sk_sp< SkColorSpace > Make(const skcms_ICCProfile &)
const void * data() const
static sk_sp< SkData > MakeFromFileName(const char path[])
sk_sp< SkImage > makeRasterImage(GrDirectContext *, CachingHint cachingHint=kDisallow_CachingHint) const
SkColorSpace * colorSpace() const
bool peekPixels(SkPixmap *pixmap) const
SkColorType colorType() const
void setColorSpace(sk_sp< SkColorSpace > colorSpace)
const SkImageInfo & info() const
void * writable_addr() const
const void * addr() const
SkAlphaType alphaType() const
static void write_png(const char *path, sk_sp< SkImage > img)
SK_API sk_sp< SkImage > DeferredFromEncodedData(sk_sp< SkData > encoded, std::optional< SkAlphaType > alphaType=std::nullopt)
SK_API sk_sp< SkImage > RasterFromPixmapCopy(const SkPixmap &pixmap)
sk_sp< const SkImage > image
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
static SkString fmt(SkColor4f c)
bool skcms_Transform(const void *src, skcms_PixelFormat srcFmt, skcms_AlphaFormat srcAlpha, const skcms_ICCProfile *srcProfile, void *dst, skcms_PixelFormat dstFmt, skcms_AlphaFormat dstAlpha, const skcms_ICCProfile *dstProfile, size_t nz)
bool skcms_MakeUsableAsDestinationWithSingleCurve(skcms_ICCProfile *profile)
const skcms_ICCProfile * skcms_sRGB_profile()
@ skcms_PixelFormat_BGRA_8888
@ skcms_PixelFormat_RGB_fff
@ skcms_PixelFormat_RGBA_8888
static bool skcms_Parse(const void *buf, size_t len, skcms_ICCProfile *profile)
@ skcms_AlphaFormat_Unpremul
@ skcms_AlphaFormat_PremulAsEncoded
int bytesPerPixel() const
SkImageInfo makeColorSpace(sk_sp< SkColorSpace > cs) const