Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Inconsistent on-screen size of image taken with camera after postlayout.

$
0
0

Hello everyone,

I have following question: How can one get the on-screen size of an image that was taken using the device's camera? Perhaps i'm doing something wrong, but basically, what I do is:

  1. Take an image with the device's camera.
  2. Create an imageView whoose image attribute is the event's media.
  3. Listen for the postlayout event and read either the rect or size attribute.

The problem is that the postlayout event get's triggered twice (in my on-development app, actually this is a number between 4 and 7). As i understand it, this behaviour is to be expected, however, sometimes the the first event has the correct values, and sometimes the second event has them. I have not seen this behaivour in images not taken by the device's camera.

The problem first appeared on an app i've been working, but I was able to water down the code to this small sample app.

A work-arround that I'm avoiding to do is checking something of the sort (size.height != 1 && size.width != 1), since a more generic solution would be nice in order to solve the problem in my "real" app.

Thanks in advance for any of your help.

debug info:

  • Application type: mobile
  • Titanium SDK: 3.5.1.GA
  • Platform: Android 5.0.1
  • Device: (physical device): Motorola Moto G
  • Host Operating System: OpenSUSE 13.1 (Bottle)
  • Titanium CLI version: 3.4.2

Logs:

[TRACE] IndexController.onImagePostlayoutEvent_Handler() #1 - JSON.stringify(e.source.size) : {"height":1,"width":1,"y":0,"x":0}
[TRACE] IndexController.onImagePostlayoutEvent_Handler() #1 - JSON.stringify(e.source.rect) : {"height":1,"width":1,"y":0,"x":0}
[TRACE] IndexController.onImagePostlayoutEvent_Handler() #2 - JSON.stringify(e.source.size) : {"height":519,"width":292,"y":0,"x":0}
[TRACE] IndexController.onImagePostlayoutEvent_Handler() #2 - JSON.stringify(e.source.rect) : {"height":519,"width":292,"y":0,"x":0}

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>