MCPcopy Create free account
hub / github.com/JetBrains/skija / execute

Method execute

tests/java/ImageTest.java:15–34  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13
14public class ImageTest implements Executable {
15 @Override
16 public void execute() throws Exception {
17 try (var surface = Surface.makeRasterN32Premul(100, 100);
18 var paint = new Paint().setColor(0xFFFF0000);
19 var path = new Path().moveTo(20, 80).lineTo(50, 20).lineTo(80, 80).closePath();)
20 {
21 var canvas = surface.getCanvas();
22 canvas.drawPath(path, paint);
23 try (var image = surface.makeImageSnapshot()) {
24 new File("target/tests/ImageTest/").mkdirs();
25 Files.write(java.nio.file.Path.of("target/tests/ImageTest/polygon_default.png"), image.encodeToData().getBytes());
26 Files.write(java.nio.file.Path.of("target/tests/ImageTest/polygon_jpeg_default.jpeg"), image.encodeToData(EncodedImageFormat.JPEG).getBytes());
27 Files.write(java.nio.file.Path.of("target/tests/ImageTest/polygon_jpeg_50.jpeg"), image.encodeToData(EncodedImageFormat.JPEG, 50).getBytes());
28 Files.write(java.nio.file.Path.of("target/tests/ImageTest/polygon_webp_default.webp"), image.encodeToData(EncodedImageFormat.WEBP).getBytes());
29 Files.write(java.nio.file.Path.of("target/tests/ImageTest/polygon_webp_50.webp"), image.encodeToData(EncodedImageFormat.WEBP, 50).getBytes());
30 // Files.write(java.nio.file.Path.of("target/tests/ImageTest/polygon_heif_default.heif"), image.encodeToData(EncodedImageFormat.HEIF).getBytes());
31 // Files.write(java.nio.file.Path.of("target/tests/ImageTest/polygon_heif_50.heif"), image.encodeToData(EncodedImageFormat.HEIF, 50).getBytes());
32 }
33 }
34 }
35}

Callers

nothing calls this directly

Calls 11

makeRasterN32PremulMethod · 0.95
closePathMethod · 0.80
lineToMethod · 0.80
moveToMethod · 0.80
getCanvasMethod · 0.80
makeImageSnapshotMethod · 0.80
writeMethod · 0.80
getBytesMethod · 0.80
encodeToDataMethod · 0.80
setColorMethod · 0.45
drawPathMethod · 0.45

Tested by

no test coverage detected