Black display.capture images bug (773)

Using the latest daily build, when using display.capture on an image that reaches outside of the screen bounds, the entire saved image becomes black instead of scaling it down according to what the screen bounds are [import]uid: 14018 topic_id: 23785 reply_id: 323785[/import]

Edit, the first time you do display.capture on an object that reaches outside of the screen bounds, it becomes black. If you then right away do another display.capture on the same object it turns out alright, except it gets cropped instead of scaled down [import]uid: 14018 topic_id: 23785 reply_id: 95719[/import]

I seem to get the same on display.save currently. Works in simulator and on Iphone device, black image on Android device. No errors.

you might want to see if your problem is similar to what christian tried to report in this thread

in his case they just blew him off, misunderstanding the problem, and just giving a “read the docs” reply.

(which missed the point entirely - he wasn’t trying to display.save within suspend/resume)

cuz there IS something wrong with display.save on Android, and I’d suggest filing yet another bug.  maybe once the volume of complaints reaches some critical mass they’ll have to actually read, understand and investigate the problem before just dismissing it out of hand as a RTFM.

christian does not have the same issue as me. He gets the image saved but instead gets the black screen. I get a black image saved and no problems with the visual appearance of the app. I’ve filed a bug with an example 320x200 image that does not go outside the screen bounds. (Actually, the saved image is 1013x675 (go figure), so it may well go outside the screen, and the problem is instead that setting event.target.width doesn’t take effect.)

I’ve filed a bug now for display.Save also. Quoting the last info I sent to the Corona devs in case it helps someone:

OK, got the idea yesterday that of course the black pic happens because the Android phone results in portrait pictures wider than 2048! It has nothing to do with Android at all!

 

Because the Iphone 4 pics were 1996px wide and the Xperia Z ones 2667px.

 

But I tested this code on an Iphone 5 with the 8Mpx camera today, which gives 2448px wide pictures. 

 

And then I get a third behavior. Not a black pic, but still a refusal to scale the picture when I change the image.width. In other words, I get a full resolution picture as for Android, but it’s not black as on Android. It’s here -> http://skapaannons.se/qr/qr-1409905365.jpg

 

(note that not all web browsers read orientation information, so you must download it and watch it on desktop if it shows a landscape picture.)

 

So:

  • on Simulator (1280x853 webcam shots), pic resize works fine

  • on Iphone 4 (1996x3000?), pic resize works fine

  • on Iphone 5 (2448x3200?), pic resize is ignored and display.Save saves a full resolution picture showing the photo

  • on Xperia Z (2667x3500?), pic resize is ignored and display.Save saves a full resolution picture showing black only

 

Hope this helps tracking it down. Obviously anything coming from the camera may very well be very high res, so some way of handling loading that file (or “resizing on disk”) would be vital to be able to use it with Corona. On Android there’s a method for a very coarse resize skipping pixels, so it’s halved in pixel size and can be loaded without hogging the heap.)

Bump. Any news on this? I did file the bug and provide info and source files and project. I also found out that capturing these huge (12 Mpixel and up) images works fine in the simulator (so a device with this good a camera must be used to provoke the bug, I think).

From this I thought that maybe the problem is in fact just the heap size. 12Mp would use at least 48MB heap. Could it be possible that we could get a function to increase the heap size, and maybe the problem would just disappear?  Edit: I got a crash log out. Well, of course it’s a problem asking for 36MB extra heap(!) on a 64MB phone, just to load a (big) .jpeg file to a small newImage. Problem seems to be Dalvik attempting to grow heap by 36MB, ioctl failing to alloc, and then Corona getting a WIN_DEATH. I’ve emailed the crash log to Corona devs for Case 35396 (my filed bug from the previous capture bug).

So in short: I’m getting this now again (in another app with trivial test-code) with a photo capture directly to file, loaded to a newImage and crashes on the same Android phone (but not on Iphone) on display.newImage().

In my opinion, the correct solution is to use the Android OS’s Input Stream parameter inSampleSize to halve the width and height if either is > 2048. If this can be used in newImage or newImageRect, that’s the best option, if not you should provide a secondary optional filename for a lower resolution image in capturePhoto options. I’ve solved this in a Java app.

I seem to get the same on display.save currently. Works in simulator and on Iphone device, black image on Android device. No errors.

you might want to see if your problem is similar to what christian tried to report in this thread

in his case they just blew him off, misunderstanding the problem, and just giving a “read the docs” reply.

(which missed the point entirely - he wasn’t trying to display.save within suspend/resume)

cuz there IS something wrong with display.save on Android, and I’d suggest filing yet another bug.  maybe once the volume of complaints reaches some critical mass they’ll have to actually read, understand and investigate the problem before just dismissing it out of hand as a RTFM.

christian does not have the same issue as me. He gets the image saved but instead gets the black screen. I get a black image saved and no problems with the visual appearance of the app. I’ve filed a bug with an example 320x200 image that does not go outside the screen bounds. (Actually, the saved image is 1013x675 (go figure), so it may well go outside the screen, and the problem is instead that setting event.target.width doesn’t take effect.)

I’ve filed a bug now for display.Save also. Quoting the last info I sent to the Corona devs in case it helps someone:

OK, got the idea yesterday that of course the black pic happens because the Android phone results in portrait pictures wider than 2048! It has nothing to do with Android at all!

 

Because the Iphone 4 pics were 1996px wide and the Xperia Z ones 2667px.

 

But I tested this code on an Iphone 5 with the 8Mpx camera today, which gives 2448px wide pictures. 

 

And then I get a third behavior. Not a black pic, but still a refusal to scale the picture when I change the image.width. In other words, I get a full resolution picture as for Android, but it’s not black as on Android. It’s here -> http://skapaannons.se/qr/qr-1409905365.jpg

 

(note that not all web browsers read orientation information, so you must download it and watch it on desktop if it shows a landscape picture.)

 

So:

  • on Simulator (1280x853 webcam shots), pic resize works fine

  • on Iphone 4 (1996x3000?), pic resize works fine

  • on Iphone 5 (2448x3200?), pic resize is ignored and display.Save saves a full resolution picture showing the photo

  • on Xperia Z (2667x3500?), pic resize is ignored and display.Save saves a full resolution picture showing black only

 

Hope this helps tracking it down. Obviously anything coming from the camera may very well be very high res, so some way of handling loading that file (or “resizing on disk”) would be vital to be able to use it with Corona. On Android there’s a method for a very coarse resize skipping pixels, so it’s halved in pixel size and can be loaded without hogging the heap.)

Bump. Any news on this? I did file the bug and provide info and source files and project. I also found out that capturing these huge (12 Mpixel and up) images works fine in the simulator (so a device with this good a camera must be used to provoke the bug, I think).

From this I thought that maybe the problem is in fact just the heap size. 12Mp would use at least 48MB heap. Could it be possible that we could get a function to increase the heap size, and maybe the problem would just disappear?  Edit: I got a crash log out. Well, of course it’s a problem asking for 36MB extra heap(!) on a 64MB phone, just to load a (big) .jpeg file to a small newImage. Problem seems to be Dalvik attempting to grow heap by 36MB, ioctl failing to alloc, and then Corona getting a WIN_DEATH. I’ve emailed the crash log to Corona devs for Case 35396 (my filed bug from the previous capture bug).

So in short: I’m getting this now again (in another app with trivial test-code) with a photo capture directly to file, loaded to a newImage and crashes on the same Android phone (but not on Iphone) on display.newImage().

In my opinion, the correct solution is to use the Android OS’s Input Stream parameter inSampleSize to halve the width and height if either is > 2048. If this can be used in newImage or newImageRect, that’s the best option, if not you should provide a secondary optional filename for a lower resolution image in capturePhoto options. I’ve solved this in a Java app.