Return a transform in either the to_ref or from_ref direction for this color space. Return an identity matrix, if the color space has no transforms.
| 865 | // Return an identity matrix, if the color space has no transforms. |
| 866 | // |
| 867 | ConstTransformRcPtr getTransformForDir(const ConstColorSpaceRcPtr & cs, ColorSpaceDirection dir) |
| 868 | { |
| 869 | ColorSpaceDirection otherDir = COLORSPACE_DIR_TO_REFERENCE; |
| 870 | if (dir == COLORSPACE_DIR_TO_REFERENCE) |
| 871 | { |
| 872 | otherDir = COLORSPACE_DIR_FROM_REFERENCE; |
| 873 | } |
| 874 | |
| 875 | ConstTransformRcPtr t = cs->getTransform(dir); |
| 876 | if (t) |
| 877 | { |
| 878 | return t; |
| 879 | } |
| 880 | |
| 881 | ConstTransformRcPtr tOther = cs->getTransform(otherDir); |
| 882 | if (tOther) |
| 883 | { |
| 884 | return invertTransform(tOther); |
| 885 | } |
| 886 | |
| 887 | // If it's the reference space, it won't have a transform, so return an identity matrix. |
| 888 | double m44[16]; |
| 889 | double offset4[4]; |
| 890 | MatrixTransform::Identity(m44, offset4); |
| 891 | MatrixTransformRcPtr p = MatrixTransform::Create(); |
| 892 | p->setMatrix(m44); |
| 893 | p->setOffset(offset4); |
| 894 | |
| 895 | return p; |
| 896 | } |
| 897 | |
| 898 | // Get a transform to convert from the source config reference space to the |
| 899 | // destination config reference space. The ref_space_type specifies whether |
no test coverage detected