I want to use the clientBundle function for GWT to load only 1 image, consisting of many sprites, using GWTCanvas. My initial solution was to simply convert ImageResource to ImageElement, but it doesn't seem to work:
public interface Bundle implements ClientBundle{ public static Bundle INSTANCE = GWT.create(Bundle .class); @Source("/img/tile1.png") public ImageResource tile1() } final GWTCanvas canvas = new GWTCanvas(400,400); canvas.drawImage(ImageElement.as(new Image(Bundle.INSTANCE.tile1()).getElement()), 0, 0);
I tried to add the image to the RootPanel first (to force the download), but this does not work either. Perhaps the timings are incorrect. Does anyone know how I can draw imageResource using GWTCanvas?
Chii
source share