public Cursor getCursor ( String ref , int x , int y ) throws IOException , LWJGLException { LoadableImageData imageData = null ; imageData = ImageDataFactory . getImageDataFor ( ref ) ; imageData . configureEdging ( false ) ; ByteBuffer buf = imageData . loadImage ( ResourceLoader . getResourceAsStream ( ref ) , true , true , null ) ; for ( int i = 0 ; i < buf . limit ( ) ; i += 4 ) { byte red = buf . get ( i ) ; byte green = buf . get ( i + 1 ) ; byte blue = buf . get ( i + 2 ) ; byte alpha = buf . get ( i + 3 ) ; buf . put ( i + 2 , red ) ; buf . put ( i + 1 , green ) ; buf . put ( i , blue ) ; buf . put ( i + 3 , alpha ) ; } try { int yspot = imageData . getHeight ( ) - y - 1 ; if ( yspot < 0 ) { yspot = 0 ; } return new Cursor ( imageData . getTexWidth ( ) , imageData . getTexHeight ( ) , x , yspot , 1 , buf . asIntBuffer ( ) , null ) ; } catch ( Throwable e ) { Log . info ( "Chances are you cursor is too small for this platform" ) ; throw new LWJGLException ( e ) ; } }
Get a cursor based on a image reference on the classpath