public class ResourceStoreExt {
private ResourceStore resourceStore;
public ResourceStoreExt(ResourceStore resourceStore) {
this.resourceStore = resourceStore;
}
public ResourceStore getResourceStore() {
return resourceStore;
}
public void captureBlob(Blob blob, String url) {
captureBlob(resourceStore, blob, url);
}
public Blob getAsBlob(String url) {
return getAsBlob(resourceStore, url);
}
private native void captureBlob(ResourceStore resourceStore, Blob blob, String url) /*-{
resourceStore.captureBlob(blob, url);
}-*/;
private native Blob getAsBlob(ResourceStore resourceStore, String url) /*-{
return resourceStore.getAsBlob(url);
}-*/;
}
Manca anche l'oggetto Canvas che è utile per il resize delle immagini:
public final class Canvas extends JavaScriptObject {
public final static String NEAREST_NEIGHBOR_FILTER = "nearest";
public final static String BILINEAR_FILTER = "bilinear";
public final static String PNG_MIMETYPE = "image/png";
public final static String JPG_MIMETYPE = "image/jpeg";
public static Canvas createInstance() {
return createInstance(Factory.getInstance());
}
private static native Canvas createInstance(Factory factory) /*-{
return factory.create("beta.canvas");
}-*/;
protected Canvas() {
}
public native int getWidth() /*-{
return this.width;
}-*/;
public native int getHeight() /*-{
return this.height;
}-*/;
public native void setWidth(int w) /*-{
this.width = w;
}-*/;
public native void setHeight(int h) /*-{
this.height = h;
}-*/;
public native void crop(int x, int y, int w, int h) /*-{
this.crop(x, y, w, h);
}-*/;
public native void decode(Blob blob) throws Exception /*-{
this.decode(blob);
}-*/;
public native Blob encode() /*-{
return this.encode();
}-*/;
public native Blob encode(String mimeType) /*-{
return this.encode(mimeType);
}-*/;
public native void resize(int w, int h) /*-{
this.resize(w, h);
}-*/;
public native void resize(int w, int h, String filter) /*-{
this.resize(w, h, filter);
}-*/;
}
E infine la classe BlobBuilder (forse poco utile):
public final class BlobBuilder extends JavaScriptObject {
public static BlobBuilder createInstance() {
return createInstance(Factory.getInstance());
}
private static native BlobBuilder createInstance(Factory factory)/*-{
return factory.create("beta.blobbuilder");
}-*/;
protected BlobBuilder() {
}
/**
*
* @param data UTF-8
*/
public native void append(String data)/*-{
this.append(data);
}-*/;
public native Blob getAsBlob()/*-{
return this.getAsBlob();
}-*/;
}