I have Image objects created from images stored in the mobile memory. I want to get the byte[] value of these Image objects. How to achieve that ?
You can use below method to convert the com.sun.lwuit.Image
to byte[].
public byte[] imageProcessing(String imageName, Image image) {
int[] rgb = image.getRGB();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
dos.writeUTF(imageName);
for (int i = 0; i < rgb.length; i++) {
dos.writeInt(rgb[i]);
}
return baos.toByteArray();
}