package be.nikiroo.jvcard.launcher;
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
-import java.io.InputStream;
import java.lang.reflect.Field;
import java.net.Socket;
import java.nio.charset.Charset;
import java.util.LinkedList;
import java.util.List;
-import javax.imageio.ImageIO;
-
import be.nikiroo.jvcard.Card;
import be.nikiroo.jvcard.Contact;
import be.nikiroo.jvcard.Data;
import be.nikiroo.jvcard.resources.RemoteBundle;
import be.nikiroo.jvcard.resources.StringId;
import be.nikiroo.jvcard.resources.TransBundle;
+import be.nikiroo.utils.IOUtils;
+import be.nikiroo.utils.Image;
import be.nikiroo.utils.ImageUtils;
import be.nikiroo.utils.StringUtils;
import be.nikiroo.utils.Version;
*
*/
public class Main {
+ /** The name of the program */
static public final String APPLICATION_TITLE = "jVcard";
static private final int ERR_NO_FILE = 1;
}
String b64;
- InputStream in = null;
+ Image img = new Image(IOUtils.toByteArray(f));
try {
- in = new FileInputStream(f);
- b64 = ImageUtils.toBase64(in);
+ b64 = img.toBase64();
} finally {
- if (in != null) {
- in.close();
- }
+ img.close();
}
// remove previous photos:
String filename = contact.toString(format, "");
File f = new File(dir, filename + ".png");
System.out.println("Saving " + f);
+ Image img = new Image(photo.getValue());
try {
- ImageIO.write(
- ImageUtils.fromBase64(photo.getValue()),
- "png", f);
+ ImageUtils.getInstance().saveAsImage(img, f,
+ "png");
} catch (IOException e) {
System.err.println(trans(
StringId.CLI_ERR_CANNOT_SAVE_PHOTO,
import be.nikiroo.jvcard.tui.KeyAction.DataType;
import be.nikiroo.jvcard.tui.KeyAction.Mode;
import be.nikiroo.jvcard.tui.UiColors;
-import be.nikiroo.utils.ImageUtils;
import be.nikiroo.utils.StringUtils;
+import be.nikiroo.utils.ui.ImageUtilsAwt;
import com.googlecode.lanterna.TerminalSize;
import com.googlecode.lanterna.gui2.BorderLayout;
if (encoding != null && encoding.getValue() != null
&& encoding.getValue().equalsIgnoreCase("b")) {
try {
- image = ImageUtils.fromBase64(photo.getValue());
+ be.nikiroo.utils.Image img = new be.nikiroo.utils.Image(
+ photo.getValue());
+ try {
+ image = ImageUtilsAwt.fromImage(img);
+ } finally {
+ img.close();
+ }
} catch (Exception e) {
System.err.println("Cannot parse image for contact: "
+ contact.getPreferredDataValue("UID"));