Capturing photo at specified resolution causes Windows Phone app to crash

33 views
Skip to first unread message

cubiq1

unread,
Sep 3, 2014, 5:40:21 PM9/3/14
to codenameone...@googlegroups.com
Hi,

I posted this as an issue (#1175) and have seen it mentioned here before. When supplying dimensions when capturing an image, the Windows Phone version of the app crashes. For example:

String photoPath = Capture.capturePhoto(640, 360);

This, however, works fine:

String photoPath = Caponeture.capturePhoto();

I can't either get the Image.scale method to work without the app freezing. Is there any way to resize a captured image on Windows Phone?

Many thanks

Shai Almog

unread,
Sep 4, 2014, 1:13:39 AM9/4/14
to codenameone...@googlegroups.com
Hi,
there seems to be an issue with ImageIO on Windows Phone which seems to be a regression. We didn't have a chance to get to this yet.

cubiq1

unread,
Sep 4, 2014, 4:11:39 AM9/4/14
to codenameone...@googlegroups.com
Hi, thanks for the info. So there's currently no way to resize a captured image on a Windows Phone device, then have it Base64 encoded?

cubiq1

unread,
Sep 4, 2014, 6:42:53 AM9/4/14
to codenameone...@googlegroups.com
I thought I'd solved it by first creating a Image then scaling this image, then creating an EncodedImage from this. And finally, using EncodedImage.getImageData() but unfortunately this returns zero. Argh.

Shai Almog

unread,
Sep 4, 2014, 10:05:49 AM9/4/14
to codenameone...@googlegroups.com
Creating an encoded image will only work with ImageIO since the image needs to be encoded.

cubiq1

unread,
Sep 4, 2014, 12:03:13 PM9/4/14
to codenameone...@googlegroups.com
Strangely enough, the following code works on Windows Phone 8:

                Image img = Image.createImage(imagePath);
               
Dialog.show("Created image", img.getWidth() + "x" + img.getHeight(), "OK", null);
               
               
EncodedImage encImg = EncodedImage.createFromImage(img, true);
               
Dialog.show("Created encoded image", encImg.getWidth() + "x" + encImg.getHeight(), "OK", null);
               
                findImageLabel
(c).setIcon(encImg);
               
                c
.getComponentForm().revalidate();

So ImageIO must be working to a certain extent? It's just when getImageData() is call that things don't work as expected.

Shai Almog

unread,
Sep 5, 2014, 12:38:20 AM9/5/14
to codenameone...@googlegroups.com
ImageIO should work for either PNG or JPEG I don't recall which one.
This is due to the fact that the Windows Phone API only supports one of them.

cubiq1

unread,
Sep 5, 2014, 10:11:01 AM9/5/14
to codenameone...@googlegroups.com
It seems Windows Phone supports JPEG. Why is it that EncodedImage.getImageData() doesn't work on the platform? Or is it is likely a convoluted, underlying issue? Many thanks

Shai Almog

unread,
Sep 5, 2014, 11:38:36 AM9/5/14
to codenameone...@googlegroups.com
This should work then, I recall it did work the last time I checked that but things might have broken since.
We'll have to look into this but right now getting the new iOS VM out is higher priority.

cubiq1

unread,
Sep 5, 2014, 1:00:35 PM9/5/14
to codenameone...@googlegroups.com
Thanks--whenever you get the time. I'll have to find a workaround for now.
Reply all
Reply to author
Forward
0 new messages