Page 1 of 1

Presenting images

Posted: Fri Dec 01, 2017 3:01 pm
by atrembla
I am trying to present images in LiveCode, but they won't present. The program is running, but the images are not presenting. The program is going to the right folder, so I can't figure out what the problem is. The images are .jpg, do they need to be saved as something else?

Re: Presenting images

Posted: Fri Dec 01, 2017 3:07 pm
by Klaus
Hi atrembla,

1 welcome to the forum!

2. We need to take a look at your script(s) to be able to help, or at least a lot more info.
Sounds like a pathname problem to me, but we need to see the scripts!

3. A little "Hello" or something would not be wrong in a first posting. 8)


Best

Klaus

Re: Presenting images

Posted: Fri Dec 01, 2017 3:31 pm
by atrembla
Klaus-

1. Thank you!

2. I think my colleague might have figured it out. The images were too big for the image field.

3. I am sorry! I am new to LiveCode and programming in general. Hi everyone!

4. Thank you for your response!

Best,
atrembla

Re: Presenting images

Posted: Fri Dec 01, 2017 3:38 pm
by Klaus
Hi atrembla,

you're welcome!

Concerning 2:
OK, then you should start to use the correct terms right away!
There is no "image field" in Livecode, just an image object and a text field (object) :D

Concerning 3:
This has nothing to do with being new to LC and programming and you know it! 8)


Best

Klaus

Re: Presenting images

Posted: Fri Dec 01, 2017 6:19 pm
by FourthWorld
atrembla wrote:
Fri Dec 01, 2017 3:31 pm
I think my colleague might have figured it out. The images were too big for the image field.
Test that hypothesis carefully. In my experience, images too large to fit within the bounds of a field are simply cropped at the field's right edge. There may be something else going on there. When we learn more about how you're displaying the images in the field we can help you get that going.

Re: Presenting images

Posted: Fri Dec 01, 2017 6:27 pm
by atrembla
Thank you so much for the tip!

Re: Presenting images

Posted: Fri Dec 01, 2017 9:15 pm
by richmond62
It might be sensible to consider resizing the images to the size of the "image" on the card.

Re: Presenting images

Posted: Tue Dec 05, 2017 5:58 pm
by atrembla
Thank you for the replies!

This is my script. This is working on my colleagues PC computer, but not on my Mac. Just to help you navigate the script, the photos I am trying to use live in the StimF folder, which is in the same folder my LiveCode program lives. Also to clarify, item 2 of the example variable contains the name of the image I am trying to show.

Any idea why the images are presenting on the PC, but not presenting on my Mac (we are sharing the same program)? Any feedback would be much appreciated. :D

global data,theCurrentImage,phase1,hold position,phase1time,hold position
put card field "example" of card "main task materials" into example
set the filename of image "imgPresent" to empty
put item 2 of line 1 of example into theCurrentImage
set the filename of image"imgPresent" of card "phase 1 instructions b" to "StimF\"&theCurrentImage&""

Re: Presenting images

Posted: Tue Dec 05, 2017 6:13 pm
by Klaus
Hi atrembla,

I think the problem is that you are using the WINDOWS path delimiter BACKSLASH \, which does not work on a Mac!

Since LC ALWAYS uses the Unix pathdelimiter SLASH /, so you should use it, since this will work on Windows AND Mac and all other supported platforms!

If you are using relative pathnames and not sure what "the defaultfolder" is currently set to, you should use -> specialfolderpath("resources")
This will also work in the IDE and gives you the folder with the current stack in it!

Code: Select all

...
## set the filename of image"imgPresent" of card "phase 1 instructions b" to "StimF\"&theCurrentImage&""
## Really no need to append EMPTY -> "" at the end of a pathname?

put specialfolderpath("resources") & "/StimF" & theCurrentImage into tImagePath
set the filename of image"imgPresent" of card "phase 1 instructions b" to tImagePath
...
This will work in the IDE and also later in a standalone if you add the folder with your image(s) to the standalone via the "Copy files..." tab in the "Standalone Builder Settings".

But variable names may NOT contain a space, so I wonder how this will work for "hold position", which you declared twice:

Code: Select all

...
global data,theCurrentImage,phase1,hold position,phase1time,hold position
...

Best

Klaus

Re: Presenting images

Posted: Wed Dec 06, 2017 3:27 pm
by atrembla
Thank you! This has been very helpful. Good catch – that variable was supposed to be one word (i.e., holdposition). 8)