Adding pictures
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Adding pictures
Hi everybody, I'm new here and just started with Livecode.
My first project is going to be a program I coded in Visual Basic a few years ago. It is a Learner's License Test.
I named each picture 1.jpg, 2.jpg and so on. Each picture was linked to a question - what I did in VB was something like this:
picture = %apppath% + question_number + ".jpg"
I want to deploy this app to multiple platforms, so what would be the best and easiest way to add these pictures to my app (there are hundreds).
Thanks
My first project is going to be a program I coded in Visual Basic a few years ago. It is a Learner's License Test.
I named each picture 1.jpg, 2.jpg and so on. Each picture was linked to a question - what I did in VB was something like this:
picture = %apppath% + question_number + ".jpg"
I want to deploy this app to multiple platforms, so what would be the best and easiest way to add these pictures to my app (there are hundreds).
Thanks
Re: Adding pictures
Hi carel,
Welcome to the forum!
Translating your VB to LC:
"picture=" becomes
"%apppath%"
could be a number of things as I believe in this case it was a stored variable showing the path to your images. For cross platform simplicity I would use
"question_number"
I'm guessing this is a variable holding the file name of the image, so lets just leave that.
"+"
LC uses "&" to concatenate strings
All together:
Check out the Dictionary for some of the terms I've used and the lessons:
http://lessons.runrev.com/
Simon
EDIT: Corrected the specialFolderPath
Welcome to the forum!
Translating your VB to LC:
Code: Select all
picture = %apppath% + question_number + ".jpg"
Code: Select all
set the filename of image "myImage"
could be a number of things as I believe in this case it was a stored variable showing the path to your images. For cross platform simplicity I would use
Code: Select all
put specialFolderPath("documents") into appPath
I'm guessing this is a variable holding the file name of the image, so lets just leave that.
"+"
LC uses "&" to concatenate strings
All together:
Code: Select all
set the filename of image "myImage" to appPath & "/" & question_number & ".jpg"
http://lessons.runrev.com/
Simon
EDIT: Corrected the specialFolderPath
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Adding pictures
Use parentheses, guys!
-> set the filename of image "myImage" to (appPath & "/" & question_number & ".jpg")

-> set the filename of image "myImage" to (appPath & "/" & question_number & ".jpg")

Re: Adding pictures
Hi, thanks for the replies.
How will my pictures be added to the correct path if it is not "in" my app - shouldn't I add the images onto a card or cards? - The only reason I mentioned the apppath + .jpg is because that is how I did it in VB. In VB it was only for Windows - so I knew where the images was - but if it is cross-platform, then the images will have to be "inside" the app.
I hope that make sense.
Thanks
How will my pictures be added to the correct path if it is not "in" my app - shouldn't I add the images onto a card or cards? - The only reason I mentioned the apppath + .jpg is because that is how I did it in VB. In VB it was only for Windows - so I knew where the images was - but if it is cross-platform, then the images will have to be "inside" the app.
I hope that make sense.
Thanks
Re: Adding pictures
Hi carel,
how do you create "apppath" on WIndows?
I'm sure we can modify it to also fit the Mac
Or is "apppath" a build-in function in VB?
Best
Klaus
how do you create "apppath" on WIndows?
I'm sure we can modify it to also fit the Mac

Or is "apppath" a build-in function in VB?
Best
Klaus
Re: Adding pictures
Hi Klaus,
It's been a few years ago - I don't remember exactly, but it does not matter, it was just an example.
I think I was not clear enough: By cross-platform I mean other devices like I-pad or Android - so I won't have access to the file system eg: C:\images or whatever - so I think I would have to import the pictures into my app ??
Thanks again,
Carel
It's been a few years ago - I don't remember exactly, but it does not matter, it was just an example.
I think I was not clear enough: By cross-platform I mean other devices like I-pad or Android - so I won't have access to the file system eg: C:\images or whatever - so I think I would have to import the pictures into my app ??
Thanks again,
Carel
Re: Adding pictures
Hi Carel,
But sure you can include the images directly in the stack, provided it doesn't make the app to big. Apple allows a max of 50 or 60 Mb apps.
Why I'd use the documents folder is it allows one to change just an image, which means you don't have to update the whole app. Constants like button icon graphics I'd include in the stack.
I think your VB script was saying the right things and can be directly translated as I have shown (with Klaus's addition).
Simon
Thats why I gave you specialFolderPath("documents") it's the same on both Android and iOS.so I won't have access to the file system eg: C:\images or whatever
But sure you can include the images directly in the stack, provided it doesn't make the app to big. Apple allows a max of 50 or 60 Mb apps.
Why I'd use the documents folder is it allows one to change just an image, which means you don't have to update the whole app. Constants like button icon graphics I'd include in the stack.
I think your VB script was saying the right things and can be directly translated as I have shown (with Klaus's addition).
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
-
- VIP Livecode Opensource Backer
- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
- Contact:
Re: Adding pictures
Hi Carel
When you make a LiveCode StandAlone you can include files (and folders) to be included in with your actual app so that when installed on a target machine you could have your store of images which can be called on as Klaus explained. Each OS needs to be treated differently as regards where the images will be located and how they can be referenced (and iOS and Android do it differently again) but if you have a lot of images the most efficient way to proceed, instead of having a bloated app, is to send out your software with accompanying image files.
Kind regards
Dave
When you make a LiveCode StandAlone you can include files (and folders) to be included in with your actual app so that when installed on a target machine you could have your store of images which can be called on as Klaus explained. Each OS needs to be treated differently as regards where the images will be located and how they can be referenced (and iOS and Android do it differently again) but if you have a lot of images the most efficient way to proceed, instead of having a bloated app, is to send out your software with accompanying image files.
Kind regards
Dave
"...this is not the code you are looking for..."
Re: Adding pictures
Thanks Dave - I did not know I could include the images separately.
And thanks to you too Simon.
And thanks to you too Simon.
-
- VIP Livecode Opensource Backer
- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
- Contact:
Re: Adding pictures
Yes its amazing what you can learn on the forum (I know I have in the past, and still do of course) - BTW I do a similar thing with sending out accompanying audio files - and you can also have accompanying text files etc
"...this is not the code you are looking for..."