public Lwjgl3MouseCursor(final long glfwWindow, @Nonnull final String cursorImageFilename, final int hotspotX, final int hotspotY, @Nonnull final NiftyResourceLoader resourceLoader) throws IOException { this.glfwWindow = glfwWindow; ImageLoader imageLoader = ImageLoaderFactory.createImageLoader(cursorImageFilename); InputStream imageStream = resourceLoader.getResourceAsStream(cursorImageFilename); if (imageStream == null) { throw new IOException("Cannot find / load mouse cursor image file: [" + cursorImageFilename + "]."); } try { ByteBuffer imageData = imageLoader.loadAsByteBufferARGB(imageStream, true); imageData.rewind(); GLFWImage image = new GLFWImage(imageData); cursor = glfwCreateCursor(image, hotspotX, hotspotY); } finally { try { imageStream.close(); } catch (IOException e) { log.log(Level.INFO, "An error occurred while closing the InputStream used to load mouse cursor image: " + "[" + cursorImageFilename + "].", e); } } }
public LwjglMouseCursor( @Nonnull final String cursorImageFilename, final int hotspotX, final int hotspotY, @Nonnull final NiftyResourceLoader resourceLoader) throws IOException { ImageLoader imageLoader = ImageLoaderFactory.createImageLoader(cursorImageFilename); InputStream imageStream = resourceLoader.getResourceAsStream(cursorImageFilename); if (imageStream == null) { throw new IOException("Cannot find / load mouse cursor image file: [" + cursorImageFilename + "]."); } try { ByteBuffer imageData = imageLoader.loadAsByteBufferARGB(imageStream, true); imageData.rewind(); int width = imageLoader.getImageWidth(); int height = imageLoader.getImageHeight(); cursor = new Cursor(width, height, hotspotX, height - hotspotY - 1, 1, imageData.asIntBuffer(), null); } catch (LWJGLException e) { throw new IOException(e); } finally { try { imageStream.close(); } catch (IOException e) { log.log(Level.INFO, "An error occurred while closing the InputStream used to load mouse cursor image: " + "[" + cursorImageFilename + "].", e); } } }