aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkICC.h
blob: 9d2ada347e432bcfa35eadc4a7308704f08a1558 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
 * Copyright 2016 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SkICC_DEFINED
#define SkICC_DEFINED

#include "SkData.h"
#include "SkRefCnt.h"

struct SkColorSpaceTransferFn;

SK_API sk_sp<SkData> SkWriteICCProfile(const SkColorSpaceTransferFn&, const float toXYZD50[9]);

namespace SkICC {
    static inline sk_sp<SkData> WriteToICC(const SkColorSpaceTransferFn& fn,
                                           const SkMatrix44& toXYZD50) {
        if (toXYZD50.get(3,0) == 0 && toXYZD50.get(3,1) == 0 && toXYZD50.get(3,2) == 0 &&
            toXYZD50.get(3,3) == 1 &&
            toXYZD50.get(0,3) == 0 && toXYZD50.get(1,3) == 0 && toXYZD50.get(2,3) == 0) {

            float m33[9];
            for (int r = 0; r < 3; r++)
            for (int c = 0; c < 3; c++) {
                m33[3*r+c] = toXYZD50.get(r,c);
            }
            return SkWriteICCProfile(fn, m33);

        }
        return nullptr;
    }
}

#endif//SkICC_DEFINED