ImageFactory.imageAsResized returns null

為{幸葍}努か 提交于 2019-12-12 13:25:12

问题


I tried to use ImageFactory.imageAsResized for resizing images.

but some times for some images it returns null.

I want to know is there any specification for images that we want to upload.???

given code may show my problem

var saveImageData = ImageFactory.imageAsResized(image, {
                        width : 480,
                        height : 360
                    });

        if (saveImageData !== null) {
        var toast = Titanium.UI.createNotification({
                    duration : 1000,
                    message : "save true "+saveImageData
                });
                toast.show();

    } else{
        var toast = Titanium.UI.createNotification({
                duration : 1000,
                message : "Problem in image resizing "+saveImageData
                        });
                toast.show();
};

in this above code some times i got null.whats is the reason for that?

Is it based on image size that we uploading?

if it is correct.. then for same size image its shows some times null,some times not null. whats is this problem.i cant able to handle this ImageFactory functionality.

please give any solution.because i stucked with this problem on my app.

Thanks all.


回答1:


First, check if image is not null. Secondly instead of using the ImageFactory use the builtin method. i.e Titanium.Blob.imageAsResized

I assume that "image" variable has the blod data. so you can just call image.imageAsResized(480,360);

Hope this helps



来源:https://stackoverflow.com/questions/21729912/imagefactory-imageasresized-returns-null

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!