public static final String toDataURL(final ImageElement element) { final ScratchCanvas canvas = new ScratchCanvas(element.getWidth(), element.getHeight()); canvas.getContext().drawImage(element, 0, 0); return canvas.toDataURL(); }
public static final String toDataURL(ImageElement element, DataURLType mimetype, double quality) { if (null == mimetype) { mimetype = DataURLType.PNG; } ScratchCanvas canvas = new ScratchCanvas(element.getWidth(), element.getHeight()); canvas.getContext().drawImage(element, 0, 0, element.getWidth(), element.getHeight()); return canvas.toDataURL(mimetype, quality); }