2
votes

I stumbled upon a problem during my work with codename one and the parse4cn1 plugin. I try to upload an image which I took with the capture module of codename one. According to the documentation of parse4cn1 I have to convert the image into “Bytes” with the “getBytes” function. But according to the Codename one documentation getBytes only works with Strings and not with images. Do you know how to “convert” the image appropriately?

I have been using this documentation, the section "uploading files": https://github.com/sidiabale/parse4cn1/wiki/Usage-Examples#uploading-files

1

1 Answers

0
votes

getBytes() is a method of EncodedImage not image. An encoded image can map to a PNG or JPEG and is a subclass of Image. You can use EncodedImage.create*() methods to load an EncodedImage directly or convert an existing image to an EncodedImage:

EncodedImage e = EncodedImage.createFromImage(img, false);

The second argument indicates if this should become a PNG or JPEG. If the image includes transparent/translucent pixels use PNG. If the image is a photo use JPEG.