[TIMOB-23462] Android: blob.getWidth() returns wrong width value in imageView
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | None |
| Status | Closed |
| Resolution | Invalid |
| Resolution Date | 2016-06-01T20:49:15.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | n/a |
| Components | Android |
| Labels | n/a |
| Reporter | Sharif AbuDarda |
| Assignee | Eric Merriman |
| Created | 2016-06-01T19:18:56.000+0000 |
| Updated | 2017-03-24T18:02:02.000+0000 |
Description
Hello, In Android, blob.getWidth() returns wrong width value in imageView.
Step To Reproduce
1. Put a image in assets/android folder. 2. Use the below Code. 3. Make the change in image name. 4. Run the project. index.xml
<Alloy>
<Window class="container">
</Window>
</Alloy>
index.js
var imgView = Ti.UI.createImageView({image:'/images/img_yo_face.png'});
var blob = imgView.toImage();
Titanium.API.info (blob.getWidth());
$.index.open();
toImage() is used when you want to transform a view into a bitmap. The view's width and height won't be measure until it is visible on screen. Since the above example did not add the imageView to any window/view, width and height values are not true values. Since you have an imageView, if you want the bitmaps bounds, you can use:
That should work even when the view isn't visible.Closing ticket as invalid with reference to the above comments.