Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sat Dec 16, 2017 11:46 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Loading folder of pictures into array
PostPosted: Sun Apr 14, 2013 9:33 am 
Offline

Joined: Tue Jun 13, 2006 10:32 am
Posts: 44
I have a folder of jpeg pictures which I wish to load into a global array. I have tried the following, but it does not seem to work:


Dim f As FolderItem
Dim count As Integer
dim p As picture

f = SpecialFolder.preferences.child("JigPictures") //-- folder of jpeg pictures
count = f.Count
if f <> nil then
For i As Integer = 1 to count
gPicFile(i) = Picture.Open (f)
next
else
msgBox "No file of that name"
return
end if


I am no expert and apologise for what must seem an elementary question. Would appreciate an answer!

owen


Top
 Profile  
Reply with quote  
 Post subject: Re: Loading folder of pictures into array
PostPosted: Sun Apr 14, 2013 11:10 am 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
Dim f As FolderItem
Dim count As Integer
dim p As picture

f = SpecialFolder.preferences.child("JigPictures") //-- folder of jpeg pictures
count = f.Count
if f <> nil then
For i As Integer = 1 to count
p = Picture.Open (f)
gPicFile.append p
next
else
msgBox "No file of that name"
return
end if


Assumes that gPicFile is GLOBAL and defined like this

DIM gPicFile(-1) as picture

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: Loading folder of pictures into array
PostPosted: Mon Apr 15, 2013 9:58 am 
Offline

Joined: Tue Jun 13, 2006 10:32 am
Posts: 44
Thanks Dave for your prompt reply; I have tried it but it still does not load the pics.
The code runs but the debugger shows gPicFile(1 to 10) as nil. I'm baffled.


Top
 Profile  
Reply with quote  
 Post subject: Re: Loading folder of pictures into array
PostPosted: Mon Apr 15, 2013 10:01 am 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
p = Picture.Open (f.trueitem(i))

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: Loading folder of pictures into array
PostPosted: Thu Apr 18, 2013 9:24 am 
Offline

Joined: Tue Jun 13, 2006 10:32 am
Posts: 44
Hi Dave
I've tried your suggestion of
p = picture.open (f.trueitem(i))
and it works. Many thanks


Top
 Profile  
Reply with quote  
 Post subject: Re: Loading folder of pictures into array
PostPosted: Thu May 02, 2013 10:05 pm 
Offline
User avatar

Joined: Fri Sep 30, 2005 11:00 am
Posts: 583
Location: Beautiful Taiwan
obt wrote:
Hi Dave
I've tried your suggestion of
p = picture.open (f.trueitem(i))
and it works. Many thanks

I'm pleased to hear that Dave was able to help, I do have a question though. Why are you loading so many pictures all at once?

If you are going to be using them all, say drawing them all onto a single page, it makes sense. However if you are creating a batch processing system or slideshow app, you may want to consider holding the folderitem and only loading the picture when you actually need it. This will help keep your app memory usage down. Storing many images in memory when you don't need to will help you reach your memory limit very fast!

_________________
Sam Rowlands
rMBP 15" @ 10.8 & '08 MBA 13" @ 10.6 + 10.7, RB2012
http://www.ohanaware.com/
AppWrapper - Prepare Apps for Mac App Store & OS X 10.8 - http://www.ohanaware.com/appwrapper/


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group