예제 #1
0
  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();
  }
예제 #2
0
  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);
  }