Importing and displaying images

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Gautami
Posts: 35
Joined: Tue Aug 06, 2013 5:25 am

Importing and displaying images

Post by Gautami » Sun Aug 25, 2013 11:13 am

Hi all,

I am trying to import about 100 pictures from a folder and displaying them in thumbnail size in a datagrid.
I edited the template stack and put in this codes.

In the button:

Code: Select all

     
 put specialfolderpath("desktop") &"/images" into tfolder
   set the defaultfolder to tfolder
   put the files into theDataA
   filter theDataA without ".DS_Store"
    
    repeat for each line xline in theDataA
       put quote & tfolder & "/" & xLine & quote & return into theDataA[xline]["Image URL"]
   end repeat
And in the row template

Code: Select all

on FillInData pDataArray
   set the filename of image "image" of me to pDataArray["Image URL"]
end FillInData
The problem is that nothing gets displayed, only an outline of the image field.

Thank you and any help will be appreciated!

Cheers,
Gautami

Klaus
Posts: 14193
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Importing and displaying images

Post by Klaus » Sun Aug 25, 2013 11:49 am

HI Gautami,

well, you have QUOTES and a RETURN (!) in the filenames, remove them and it should work:

Code: Select all

...
repeat for each line xline in theDataA
   ## THIS produces a valid filepath:
   put tfolder & "/" & xLine into theDataA[xline]["Image URL"]
end repeat
...
Best

Klaus

Gautami
Posts: 35
Joined: Tue Aug 06, 2013 5:25 am

Re: Importing and displaying images

Post by Gautami » Sun Aug 25, 2013 12:30 pm

Hey Klaus,

I tried and still I get a blank datagrid.
:(
Is there any other way I could get the user to import pictures from a folder
and display them??

Regards,
G

Klaus
Posts: 14193
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Importing and displaying images

Post by Klaus » Sun Aug 25, 2013 12:37 pm

Ah, I think I got it!

When creating the array for the datagrid you use the FILENAMES of the images as the keys,
but the keys need to be NUMERIC -> 1 - N!

Code: Select all

...
## We need to create numerical keys for the datagrid array!
put 1 into tCounter

## xline will hold the filename of the images!
repeat for each line xline in theDataA
     put tfolder & "/" & xLine into theDataA[tCounter]["Image URL"]
     add 1 to tCounter
end repeat
...
Best

Klaus

Gautami
Posts: 35
Joined: Tue Aug 06, 2013 5:25 am

Re: Importing and displaying images

Post by Gautami » Sun Aug 25, 2013 3:02 pm

Still not working :(
i have attached the file here. Maybe you can see what I am doing wrong.

Thanks for all the help.

G
Attachments
image.livecode.zip
(5.17 KiB) Downloaded 253 times

Post Reply