【问题标题】:Titanium 2 : get image size?Titanium 2:获取图像大小?
【发布时间】:2012-07-20 14:23:22
【问题描述】:

我使用钛。我使用 Android Nexus S 进行测试。

我有一个来自画廊的照片。我找不到获取这张照片的宽度和高度的方法。

我已经看到了一些关于 auto 属性的提示,但是这个提示似乎没有运行 因为钛 2.0


第一次尝试

Ti.Media.openPhotoGallery({
    success : function(e) {
        alert(e.media.width + " x " + e.media.height);
}});

结果“0 x 0”


第二次尝试

Ti.Media.openPhotoGallery({
    success : function(e) {
        var img = Ti.UI.createImageView({
                    image : e.media, 
                    width: 'auto', 
                    height: 'auto' });
        alert(img.width + " x " + img.height);
}});

结果“自动 x 自动”


所以,我的简单问题:

如何获取从图库中获取的照片的尺寸?

【问题讨论】:

    标签: android iphone titanium


    【解决方案1】:

    经过几次尝试(在写这个问题的过程中),我找到了它:

    Ti.Media.openPhotoGallery({
        success : function(e) {
            var img = Ti.UI.createImageView({
                        image : e.media, 
                        width: 'auto', 
                        height: 'auto' });
            alert(img.toImage().width + " x " + img.toImage().height);
    }});
    

    提示是使用 img.toImage().width

    【讨论】:

      猜你喜欢
      • 2012-07-20
      • 2012-04-15
      • 1970-01-01
      • 1970-01-01
      • 2020-03-14
      • 2011-12-15
      • 2018-07-11
      • 2012-01-21
      • 2023-03-28
      相关资源
      最近更新 更多