MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / loadResource

Method loadResource

src/main/java/fieldbox/ui/Cursors.java:47–76  ·  view source on GitHub ↗
(String res)

Source from the content-addressed store, hash-verified

45 }
46
47 protected static long loadResource(String res) {
48 URL arrowFile = Cursors.class.getClassLoader()
49 .getResource("images/"+res);
50
51 String file = arrowFile.getFile();
52 file= new File(file).getAbsolutePath();
53 ByteBuffer dest = ByteBuffer.allocateDirect(3 * cursorSize * cursorSize);
54 ByteBuffer destRGBA = ByteBuffer.allocateDirect(4 * cursorSize * cursorSize);
55 j.decompress(file, dest, cursorSize, cursorSize);
56
57 for (int i = 0; i < cursorSize * cursorSize; i++) {
58 byte r = dest.get();
59 byte g = dest.get();
60 byte b = dest.get();
61 destRGBA.put(r);
62 destRGBA.put(g);
63 destRGBA.put(b);
64 destRGBA.put((byte) (255 - (b & 0xff)));
65 }
66
67
68 dest.rewind();destRGBA.rewind();
69
70 GLFWImage g = GLFWImage.calloc();
71 g.height(cursorSize);
72 g.width(cursorSize);
73 g.pixels(destRGBA);
74
75 return glfwCreateCursor(g, 16, 16);
76 }
77
78 static public void arrowRight(Window window) {
79 if (arrowRight == 0) arrowRight = loadResource("arrowRight.jpg");

Callers 4

arrowLeftMethod · 0.95
arrowRightMethod · 0.95
arrowDownMethod · 0.95
arrowUpMethod · 0.95

Calls 5

getFileMethod · 0.80
widthMethod · 0.80
decompressMethod · 0.65
getMethod · 0.65
putMethod · 0.45

Tested by

no test coverage detected