done

On Thursday, March 2, 2017 at 11:30:17 AM UTC+1, xha...@googlemail.com 
wrote:
>
> Hey ho!
>
> I may found a bug in the method mentioned in the title.
>
> My usecase:
>
> We want to send the image from a SignatureComponent base64 encoded to the 
> server.
>
> This is my sample code:
> SignatureComponent asSignature = (SignatureComponent) valueComponent;
> Image signatureImage = asSignature.getSignatureImage();
> EncodedImage encodedImage = URLImage.createFromImage(signatureImage, true);
> String asB64 = Base64.encode(encodedImage.getImageData());
>
>
> But i always get a black screen out of it and the base64 string is always 
> the same, no matter what image will be returned from line 2 in the code 
> above.
> I looked into the the "createFromImage" method and saw these 4 lines:
>
> ByteArrayOutputStream bo = new ByteArrayOutputStream();
> io.save(i, bo, format, 0.9f);
> Util.cleanup(bo);
> EncodedImage enc = EncodedImage.create(bo.toByteArray());
>
> I suppose the Util.cleanup method is like a Stream.close() equivalent, so 
> the last line "bo.toByteArray()" cant work propperly if the stream is 
> closed before. If you switch  the last 2 lines, it works as expected and i 
> get a valid image.
>

-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to codenameone-discussions+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/393cc647-89f5-4d9f-b672-83aeba930e26%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to