/** * Asynchronously loads and returns the image at the specified URL. The width and height of the * image will be the supplied {@code width} and {@code height} until the image is loaded. * <em>Note:</em> on non-HTML platforms, this spawns a new thread for each loaded image. Thus, * attempts to load large numbers of remote images simultaneously may result in poor performance. */ public Image getRemoteImage (String url, int width, int height) { Exception error = new Exception( "Remote image loading not yet supported: " + url + "@" + width + "x" + height); ImageImpl image = createImage(false, width, height, url); image.fail(error); return image; }
/** * Asynchronously loads and returns the image at the specified URL. The width and height of the * image will be the supplied {@code width} and {@code height} until the image is loaded. * <em>Note:</em> on non-HTML platforms, this spawns a new thread for each loaded image. Thus, * attempts to load large numbers of remote images simultaneously may result in poor performance. */ public Image getRemoteImage (String url, int width, int height) { Exception error = new Exception( "Remote image loading not yet supported: " + url + "@" + width + "x" + height); ImageImpl image = createImage(false, width, height, url); image.fail(error); return image; }
/** * Asynchronously loads and returns an image. The calling thread will not block. The returned * image will not be immediately usable, will not report valid width and height, and cannot be * immediately rendered into a canvas or converted into a texture. Use {@link Image#state} to be * notified when loading succeeds or fails. * * @param path the path to the image asset. */ public Image getImage (final String path) { final ImageImpl image = createImage(true, 0, 0, path); exec.invokeAsync(new Runnable() { public void run () { try { image.succeed(load(path)); } catch (Throwable t) { image.fail(t); } } }); return image; }
/** * Asynchronously loads and returns an image. The calling thread will not block. The returned * image will not be immediately usable, will not report valid width and height, and cannot be * immediately rendered into a canvas or converted into a texture. Use {@link Image#state} to be * notified when loading succeeds or fails. * * @param path the path to the image asset. */ public Image getImage (final String path) { final ImageImpl image = createImage(true, 0, 0, path); exec.invokeAsync(new Runnable() { public void run () { try { image.succeed(load(path)); } catch (Throwable t) { image.fail(t); } } }); return image; }
/** * Synchronously loads and returns an image. The calling thread will block while the image is * loaded from disk and decoded. When this call returns, the image's width and height will be * valid, and the image can be immediately converted to a texture and drawn into a canvas. * * @param path the path to the image asset. * @throws UnsupportedOperationException on platforms that cannot support synchronous asset * loading (HTML). */ public Image getImageSync (String path) { ImageImpl image = createImage(false, 0, 0, path); try { image.succeed(load(path)); } catch (Throwable t) { image.fail(t); } return image; }
/** * Synchronously loads and returns an image. The calling thread will block while the image is * loaded from disk and decoded. When this call returns, the image's width and height will be * valid, and the image can be immediately converted to a texture and drawn into a canvas. * * @param path the path to the image asset. * @throws UnsupportedOperationException on platforms that cannot support synchronous asset * loading (HTML). */ public Image getImageSync (String path) { ImageImpl image = createImage(false, 0, 0, path); try { image.succeed(load(path)); } catch (Throwable t) { image.fail(t); } return image; }