code: private void parseAndCallback(String rawImage, ScreenshotCallback callback)
    {
      if(callback == null)
      {
        return;
      }
      
      // find the mime type
      final String[] typeInfoAndData = rawImage.split(",");
      String[] mimeAndEncoding = typeInfoAndData[0].replaceFirst("data:", "").split(";");
      if(typeInfoAndData.length == 2 &&
        mimeAndEncoding.length == 2 
        && "base64".equalsIgnoreCase(mimeAndEncoding[1]))
      {
        byte[] result = Base64.decodeBase64(typeInfoAndData[1]);
        callback.screenshotReceived(result, mimeAndEncoding[0]);
      }
  
    }
docs: Takes a raw string representing the result of the toDataURL() function
  of the HTML5 canvas and calls the callback with a proper mime type
  and the bytes of the image.
  
  @see  <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-canvas-todataurl">http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-canvas-todataurl</
  @param rawImage The encoded image
  @param callback The callback to call with the result.
  @return