[b]1. 从byte[]得到Image[/b]
[b]2. 从Image得到byte[][/b]
private static Image createImage(byte[] imageBytes) {
Image image = null;
try {
ByteArrayInputStream bais = new ByteArrayInputStream(imageBytes);
image = new Image(null, bais);
} catch (Exception e) {
e.printStackTrace();
}
return image;
}
[b]2. 从Image得到byte[][/b]
public static byte[] getImageBytes(Image image) throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageLoader imageLoader = new ImageLoader();
imageLoader.data = new ImageData[] { image.getImageData() };
imageLoader.save(baos, image.type);
byte[] imageByteArray = baos.toByteArray();
try {
baos.close();
} catch (Exception e) {
e.printStackTrace();
}
return imageByteArray;
}