0
以下代碼大部分工作正常,但有時在更改爲blob後,圖像視圖不顯示圖像。將圖像視圖變爲blob並不總是有效.toImage();
//store in temp image view, convert to blob
imageViewTemp.image = "imagename.jpg"
blob = imageViewTemp.toBlob();
albumTitle = data[x].name + ' (' + numberPhotos + ')';
var row = Titanium.UI.createTableViewRow({
titleAlb : data[x].name,
width : '100%',
height : 'auto'
});
var image = Titanium.UI.createImageView({
top : 0,
left : 0,
width : '75',
height : '75'
});
var title = Titanium.UI.createLabel({
text : albumTitle,
top : 0,
left : 110,
width : 'auto',
height : 'auto'
});
var width = blob.width;
var height = blob.height;
//crop so it fits in image view
if (width > height) {
image.image = ImageFactory.imageAsCropped(blob, {
width : height,
height : height,
x : 60,
y : 0
});
} else {
image.image = ImageFactory.imageAsCropped(blob, {
width : (width - 1),
height : (width - 1),
x : 60,
y : 0
});
}
row.add(image);
row.add(title);
rows.push(row);
}
爲了改變圖像的尺寸,我使用了一個名爲image factory的模塊。之前,我可以改變它,我必須存儲tempory圖像視圖內的圖像,然後我轉換成二進制大對象:
blob = imageViewTemp.toBlob();
問題是屏幕有時呈現後,這將不起作用:
image.image = ImageFactory.imageAsCropped(blob, {
width : height,
height : height,
x : 60,
y : 0
});
Othertimes it will。
我在網上閱讀,這個問題可能與佈局後周期,但我不知道,或者如何進行
http://developer.appcelerator.com/question/174329/what-are-the-difference-between-toblob--toimage
感謝所有幫助。