Skip to content

Commit f997145

Browse files
committed
CI: check ICC profiles in svggen on Java 8
1 parent e6b026b commit f997145

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ sourceSets {
1414
srcDirs = ['src/examples/java']
1515
}
1616
resources {
17-
srcDirs = ['imag']
18-
includes = ['hdrbg.svg']
17+
srcDirs = ['src/examples/resources', 'imag']
18+
includes = ['hdrbg.svg', '**/profiles/*']
1919
}
2020
}
2121
}

src/examples/java/io/sf/carte/example/EchoSVGTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public void testTranscoding() throws Exception {
151151

152152
trans.transcode(input, output);
153153

154-
assertTrue(ostream.size() > 1070, "Image had size of only " + ostream.size() + ".");
154+
assertTrue(ostream.size() > 1000, "Image had size of only " + ostream.size() + ".");
155155
}
156156

157157
private Reader loadDocumentFromClasspath(String filename) {

src/examples/java/io/sf/carte/example/FontDecorationPainter.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,17 @@
1515
import java.awt.Font;
1616
import java.awt.Graphics2D;
1717
import java.awt.RenderingHints;
18+
import java.awt.Transparency;
19+
import java.awt.color.ICC_ColorSpace;
20+
import java.awt.color.ICC_Profile;
1821
import java.awt.font.TextAttribute;
1922
import java.awt.geom.Rectangle2D;
2023
import java.awt.image.BufferedImage;
24+
import java.awt.image.ComponentColorModel;
25+
import java.awt.image.DataBuffer;
26+
import java.awt.image.WritableRaster;
27+
import java.io.IOException;
28+
import java.io.InputStream;
2129
import java.util.HashMap;
2230
import java.util.Map;
2331

@@ -71,7 +79,23 @@ public void paint(Graphics2D g) {
7179

7280
private static BufferedImage createImage() {
7381
// Create an Image
74-
BufferedImage image = new BufferedImage(100, 75, BufferedImage.TYPE_INT_ARGB);
82+
// Load a profile
83+
ICC_Profile prof;
84+
try (InputStream iccStream = FontDecorationPainter.class.getResourceAsStream(
85+
"/io/sf/carte/example/profiles/Display P3.icc")) {
86+
prof = ICC_Profile.getInstance(iccStream);
87+
} catch (IOException e) {
88+
throw new IllegalStateException(e);
89+
}
90+
ICC_ColorSpace cs = new ICC_ColorSpace(prof);
91+
92+
// Create the image
93+
int[] bits = { 16, 16, 16, 16 };
94+
ComponentColorModel cm = new ComponentColorModel(cs, bits, true, false,
95+
Transparency.TRANSLUCENT, DataBuffer.TYPE_USHORT);
96+
WritableRaster raster = cm.createCompatibleWritableRaster(100, 75);
97+
BufferedImage image = new BufferedImage(cm, raster, false, null);
98+
7599
Graphics2D ig = image.createGraphics();
76100
ig.scale(.5, .5);
77101
ig.setPaint(new Color(128, 0, 0));
Binary file not shown.

0 commit comments

Comments
 (0)