0
问候。 SDK 1.6.2
从数据库缓慢加载图像
我将相机捕获的位置以及一些其他信息存储在数据库中。
我有一个窗口循环通过数据库,并以小的平铺缩略图显示图像。
的图像越,我有较长的这个窗口需要加载(保持空白,直到完成)
这里是我如何调用图片:
var imageArray = [];
var images = [];
// open and parse database
var db = Titanium.Database.open('photoDB');
var dbrows = db.execute('select id, date, image, tags from images order by date asc');
while (dbrows.isValidRow()) {
imagesArray.push({
id: dbrows.fieldByName('id'),
image:dbrows.fieldByName('image'), // image is the location of the stored image inside of applicationDataDirectory
tags:dbrows.fieldByName('tags')
});
dbrows.next();
}
dbrows.close();
db.close();
// Load in the images
for (var i = 0; i < imageArray.length; i++){
var pushleft = ((i % 4) * 76); // tile from left
var pushtop = (Math.floor(i/4) * 100); //tile from top
var file = Titanium.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, imageArray[i].image);
if(file.exists()){
images[i] = Ti.UI.createImageView({
image: file.nativePath,
width: 75,
height: 96,
left: pushleft,
top: pushtop,
store_id: imageArray[i].id,
zIndex: 99
});
win.add(images[i]);
}
}
我不知道,如果滞后是由于getFile
或者可能存储图像的大小?
我有10个图像存储,这个窗口需要13秒加载。如果我不知道要等待,我会认为它已损坏,并离开了应用程序...
有什么想法?谢谢!
亚伦,谢谢你的回复。我正在保存整个图像,因为整个图像将在稍后使用并上传到服务器。 'iOS' – joseym 2011-04-23 14:56:32
我有同样的情况,但我保存了两个版本的图像。它可能会比Wi-Fi更好地运行,但如果应用程序要通过3G使用,那么您将有一个糟糕的用户体验传输巨大的图像在线路上来回传输......恕我直言。 – 2011-04-24 15:17:09
我会给缩略图创建一个镜头,让你知道它是如何工作的。感谢提示@Aaron Saunders,我会尽快回复。创建单独的缩略图图像的 – joseym 2011-04-25 00:26:57