public void savePicture(String imagePath) {
FormManager.runOnEDT(() -> {
Log.p("imagePath" + imagePath);
try {
Image img = Image.createImage(imagePath);
String host = FileSystemStorage.getInstance().getAppHomePath();
if (!isSimulator() && "ios".equals(getPlatformName())) {
if (host.indexOf("file://") == 0 && host.indexOf("file:///") == -1) {
host = StringUtil.replaceAll(host, "file://", "file:///");
}
}
String newPath = host + Integer.toHexString((int) (System.currentTimeMillis() / 1000)) + ".jpg";
Log.p("newPath" + newPath);
OutputStream out = FileSystemStorage.getInstance().openOutputStream(newPath);
ImageIO.getImageIO().save(img, out, ImageIO.FORMAT_JPEG, 1);
img.dispose();
imagePaths.add(newPath);
revalidate();
} catch (IOException ex) {
Log.e(ex);
}
});
}