|
1 | 1 | /*
|
2 |
| - * Copyright (c) 1995, 2021, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 1995, 2022, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
|
28 | 28 | import java.awt.Transparency;
|
29 | 29 | import java.awt.color.ColorSpace;
|
30 | 30 | import java.awt.color.ICC_ColorSpace;
|
31 |
| -import sun.java2d.cmm.CMSManager; |
32 |
| -import sun.java2d.cmm.ColorTransform; |
33 |
| -import sun.java2d.cmm.PCMM; |
| 31 | +import java.awt.color.ICC_Profile; |
| 32 | +import java.util.Arrays; |
34 | 33 | import java.util.Collections;
|
35 | 34 | import java.util.Map;
|
36 | 35 | import java.util.WeakHashMap;
|
37 |
| -import java.util.Arrays; |
| 36 | + |
| 37 | +import sun.java2d.cmm.CMSManager; |
| 38 | +import sun.java2d.cmm.ColorTransform; |
| 39 | +import sun.java2d.cmm.PCMM; |
38 | 40 |
|
39 | 41 | /**
|
40 | 42 | * The {@code ColorModel} abstract class encapsulates the
|
@@ -1791,15 +1793,10 @@ static byte[] getGray8TosRGB8LUT(ICC_ColorSpace grayCS) {
|
1791 | 1793 | for (int i = 0; i <= 255; i++) {
|
1792 | 1794 | g8Tos8LUT[i] = (byte) i;
|
1793 | 1795 | }
|
1794 |
| - ColorTransform[] transformList = new ColorTransform[2]; |
| 1796 | + var srgb = ICC_Profile.getInstance(ColorSpace.CS_sRGB); |
1795 | 1797 | PCMM mdl = CMSManager.getModule();
|
1796 |
| - ICC_ColorSpace srgbCS = |
1797 |
| - (ICC_ColorSpace) ColorSpace.getInstance(ColorSpace.CS_sRGB); |
1798 |
| - transformList[0] = mdl.createTransform( |
1799 |
| - grayCS.getProfile(), ColorTransform.Any, ColorTransform.In); |
1800 |
| - transformList[1] = mdl.createTransform( |
1801 |
| - srgbCS.getProfile(), ColorTransform.Any, ColorTransform.Out); |
1802 |
| - ColorTransform t = mdl.createTransform(transformList); |
| 1798 | + ColorTransform t = mdl.createTransform(ColorTransform.Any, |
| 1799 | + grayCS.getProfile(), srgb); |
1803 | 1800 | byte[] tmp = t.colorConvert(g8Tos8LUT, null);
|
1804 | 1801 | for (int i = 0, j= 2; i <= 255; i++, j += 3) {
|
1805 | 1802 | // All three components of tmp should be equal, since
|
@@ -1832,15 +1829,10 @@ static byte[] getLinearGray16ToOtherGray8LUT(ICC_ColorSpace grayCS) {
|
1832 | 1829 | for (int i = 0; i <= 65535; i++) {
|
1833 | 1830 | tmp[i] = (short) i;
|
1834 | 1831 | }
|
1835 |
| - ColorTransform[] transformList = new ColorTransform[2]; |
| 1832 | + var lg = ICC_Profile.getInstance(ColorSpace.CS_GRAY); |
1836 | 1833 | PCMM mdl = CMSManager.getModule();
|
1837 |
| - ICC_ColorSpace lgCS = |
1838 |
| - (ICC_ColorSpace) ColorSpace.getInstance(ColorSpace.CS_GRAY); |
1839 |
| - transformList[0] = mdl.createTransform ( |
1840 |
| - lgCS.getProfile(), ColorTransform.Any, ColorTransform.In); |
1841 |
| - transformList[1] = mdl.createTransform ( |
1842 |
| - grayCS.getProfile(), ColorTransform.Any, ColorTransform.Out); |
1843 |
| - ColorTransform t = mdl.createTransform(transformList); |
| 1834 | + ColorTransform t = mdl.createTransform(ColorTransform.Any, |
| 1835 | + lg, grayCS.getProfile()); |
1844 | 1836 | tmp = t.colorConvert(tmp, null);
|
1845 | 1837 | byte[] lg16Toog8LUT = new byte[65536];
|
1846 | 1838 | for (int i = 0; i <= 65535; i++) {
|
@@ -1876,15 +1868,10 @@ static byte[] getGray16TosRGB8LUT(ICC_ColorSpace grayCS) {
|
1876 | 1868 | for (int i = 0; i <= 65535; i++) {
|
1877 | 1869 | tmp[i] = (short) i;
|
1878 | 1870 | }
|
1879 |
| - ColorTransform[] transformList = new ColorTransform[2]; |
| 1871 | + var srgb = ICC_Profile.getInstance(ColorSpace.CS_sRGB); |
1880 | 1872 | PCMM mdl = CMSManager.getModule();
|
1881 |
| - ICC_ColorSpace srgbCS = |
1882 |
| - (ICC_ColorSpace) ColorSpace.getInstance(ColorSpace.CS_sRGB); |
1883 |
| - transformList[0] = mdl.createTransform ( |
1884 |
| - grayCS.getProfile(), ColorTransform.Any, ColorTransform.In); |
1885 |
| - transformList[1] = mdl.createTransform ( |
1886 |
| - srgbCS.getProfile(), ColorTransform.Any, ColorTransform.Out); |
1887 |
| - ColorTransform t = mdl.createTransform(transformList); |
| 1873 | + ColorTransform t = mdl.createTransform(ColorTransform.Any, |
| 1874 | + grayCS.getProfile(), srgb); |
1888 | 1875 | tmp = t.colorConvert(tmp, null);
|
1889 | 1876 | byte[] g16Tos8LUT = new byte[65536];
|
1890 | 1877 | for (int i = 0, j= 2; i <= 65535; i++, j += 3) {
|
@@ -1921,16 +1908,10 @@ static short[] getLinearGray16ToOtherGray16LUT(ICC_ColorSpace grayCS) {
|
1921 | 1908 | for (int i = 0; i <= 65535; i++) {
|
1922 | 1909 | tmp[i] = (short) i;
|
1923 | 1910 | }
|
1924 |
| - ColorTransform[] transformList = new ColorTransform[2]; |
| 1911 | + var lg = ICC_Profile.getInstance(ColorSpace.CS_GRAY); |
1925 | 1912 | PCMM mdl = CMSManager.getModule();
|
1926 |
| - ICC_ColorSpace lgCS = |
1927 |
| - (ICC_ColorSpace) ColorSpace.getInstance(ColorSpace.CS_GRAY); |
1928 |
| - transformList[0] = mdl.createTransform ( |
1929 |
| - lgCS.getProfile(), ColorTransform.Any, ColorTransform.In); |
1930 |
| - transformList[1] = mdl.createTransform( |
1931 |
| - grayCS.getProfile(), ColorTransform.Any, ColorTransform.Out); |
1932 |
| - ColorTransform t = mdl.createTransform( |
1933 |
| - transformList); |
| 1913 | + ColorTransform t = mdl.createTransform(ColorTransform.Any, |
| 1914 | + lg, grayCS.getProfile()); |
1934 | 1915 | short[] lg16Toog16LUT = t.colorConvert(tmp, null);
|
1935 | 1916 | if (lg16Toog16Map == null) {
|
1936 | 1917 | lg16Toog16Map = Collections.synchronizedMap(new WeakHashMap<ICC_ColorSpace, short[]>(2));
|
|
0 commit comments