Hi,
I'm trying to crop a captured image (using Image.subImage) before uploading it as a Base64 string.
On J2ME I'm having issues converting this cropped image to Base64. The following code results in a NullPointerException:
// Method 1
ByteArrayOutputStream baos=new ByteArrayOutputStream();
ImageIO.getImageIO().save(subImage, baos, ImageIO.FORMAT_JPEG, 1);
byte[] b = baos.toByteArray();
imageBase64 = Base64.encodeNoNewline(b);
So I tried this, as Image.IO isn't supported on J2ME, but it didn't either work:
// Method 2
EncodedImage encImg = EncodedImage.createFromImage(subImage, true);
imageBase64 = Base64.encodeNoNewline(encImg.getImageData());
Is there anyway to do this on J2ME?
Thanks