use of java.awt.color.ColorSpace in project jdk8u_jdk by JetBrains.
the class CMMTests method getColorSpace.
protected static ColorSpace getColorSpace(TestEnvironment env) {
ColorSpace cs;
//(Boolean)env.getModifier(usePlatfromProfiles);
Boolean usePlatfrom = true;
int cs_code = env.getIntValue(csList);
if (usePlatfrom) {
cs = ColorSpace.getInstance(cs_code);
} else {
String resource = "profiles/";
switch(cs_code) {
case ColorSpace.CS_CIEXYZ:
resource += "CIEXYZ.pf";
break;
case ColorSpace.CS_GRAY:
resource += "GRAY.pf";
break;
case ColorSpace.CS_LINEAR_RGB:
resource += "LINEAR_RGB.pf";
break;
case ColorSpace.CS_PYCC:
resource += "PYCC.pf";
break;
case ColorSpace.CS_sRGB:
resource += "sRGB.pf";
break;
default:
throw new RuntimeException("Unknown color space: " + cs_code);
}
try {
InputStream is = CMMTests.class.getResourceAsStream(resource);
ICC_Profile p = ICC_Profile.getInstance(is);
cs = new ICC_ColorSpace(p);
} catch (IOException e) {
throw new RuntimeException("Unable load profile from resource " + resource, e);
}
}
return cs;
}
use of java.awt.color.ColorSpace in project jdk8u_jdk by JetBrains.
the class RGBColorConvertTest method main.
public static void main(String[] args) {
BufferedImage src = new BufferedImage(256, 3, BufferedImage.TYPE_INT_RGB);
BufferedImage dst = new BufferedImage(256, 3, BufferedImage.TYPE_INT_RGB);
for (int i = 0; i < 256; i++) {
src.setRGB(i, 0, i);
src.setRGB(i, 1, i << 8);
src.setRGB(i, 2, i << 16);
}
ColorSpace srcColorSpace = src.getColorModel().getColorSpace();
ColorConvertOp op = new ColorConvertOp(srcColorSpace, srcColorSpace, null);
op.filter(src, dst);
int errCount = 0;
for (int i = 0; i < src.getWidth(); i++) {
for (int j = 0; j < src.getHeight(); j++) {
int scol = src.getRGB(i, j);
int dcol = dst.getRGB(i, j);
if (scol != dcol) {
System.err.println("(" + i + "," + j + ") : " + Integer.toHexString(scol) + "!=" + Integer.toHexString(dcol));
errCount++;
}
}
}
if (errCount > 0) {
throw new RuntimeException(errCount + " pixels are changed by " + "transform between the same ICC color " + "spaces");
}
}
use of java.awt.color.ColorSpace in project jdk8u_jdk by JetBrains.
the class ITSDataType method main.
public static void main(String[] args) {
ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
int[] bankIndices = new int[] { 1 };
int[] bandOffsets = new int[] { 0 };
// test createBanded()
for (int i = 0; i < dataTypes.length; i++) {
int dataType = dataTypes[i];
try {
ImageTypeSpecifier.createBanded(cs, bankIndices, bandOffsets, dataType, false, false);
} catch (IllegalArgumentException e) {
throw new RuntimeException("createBanded() test failed for " + "dataType = " + dataType);
}
}
// test createInterleaved()
for (int i = 0; i < dataTypes.length; i++) {
int dataType = dataTypes[i];
try {
ImageTypeSpecifier.createInterleaved(cs, bandOffsets, dataType, false, false);
} catch (IllegalArgumentException e) {
throw new RuntimeException("createInterleaved() test failed " + "for dataType = " + dataType);
}
}
}
use of java.awt.color.ColorSpace in project jdk8u_jdk by JetBrains.
the class TestCompressionBI_BITFIELDS method compareImages.
protected void compareImages(BufferedImage src, BufferedImage dst) {
ColorSpace srcCS = src.getColorModel().getColorSpace();
ColorSpace dstCS = dst.getColorModel().getColorSpace();
if (!srcCS.equals(dstCS) && srcCS.getType() == ColorSpace.TYPE_GRAY) {
System.out.println("Workaround color difference with GRAY.");
BufferedImage tmp = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_INT_RGB);
Graphics g = tmp.createGraphics();
g.drawImage(src, 0, 0, null);
src = tmp;
}
int y = h / 2;
for (int i = 0; i < colors.length; i++) {
int x = dx * i + dx / 2;
int srcRgb = src.getRGB(x, y);
int dstRgb = dst.getRGB(x, y);
if (srcRgb != dstRgb) {
throw new RuntimeException("Test failed due to color difference: " + "src_pixel=" + Integer.toHexString(srcRgb) + "dst_pixel=" + Integer.toHexString(dstRgb));
}
}
}
use of java.awt.color.ColorSpace in project jdk8u_jdk by JetBrains.
the class AlphaTest method main.
public static void main(String[] args) {
ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
ColorConvertOp op = new ColorConvertOp(cs, null);
// create source image filled with an opaque color
BufferedImage src = createSrc();
int srcAlpha = getAlpha(src);
System.out.printf("Src alpha: 0x%02x\n", srcAlpha);
// create clear (transparent black) destination image
BufferedImage dst = createDst();
int dstAlpha = getAlpha(dst);
System.out.printf("Dst alpha: 0x%02x\n", dstAlpha);
dst = op.filter(src, dst);
dstAlpha = getAlpha(dst);
// we expect that destination image is opaque
// i.e. alpha is transferred from source to
// the destination
System.out.printf("Result alpha: 0x%02x\n", dstAlpha);
if (srcAlpha != dstAlpha) {
throw new RuntimeException("Test failed!");
}
System.out.println("Test passed");
}
Aggregations