Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23462] Android: blob.getWidth() returns wrong width value in imageView

GitHub Issuen/a
TypeBug
PriorityNone
StatusClosed
ResolutionInvalid
Resolution Date2016-06-01T20:49:15.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAndroid
Labelsn/a
ReporterSharif AbuDarda
AssigneeEric Merriman
Created2016-06-01T19:18:56.000+0000
Updated2017-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();

Observed result

In console the "Titanium.API.info (blob.getWidth());" return value is 1.

Expected result

"Titanium.API.info (blob.getWidth());" should return the aclual width value. Regards, Sharif

Comments

  1. Hieu Pham 2016-06-01

    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:
       imgView.toBlob();
       
    That should work even when the view isn't visible.
  2. Lee Morris 2017-03-24

    Closing ticket as invalid with reference to the above comments.

JSON Source