Presenting images

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
atrembla
Posts: 5
Joined: Thu Nov 30, 2017 10:53 pm

Presenting images

Post by atrembla » Fri Dec 01, 2017 3:01 pm

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?

Klaus
Posts: 9619
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Presenting images

Post by Klaus » Fri Dec 01, 2017 3:07 pm

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

atrembla
Posts: 5
Joined: Thu Nov 30, 2017 10:53 pm

Re: Presenting images

Post by atrembla » Fri Dec 01, 2017 3:31 pm

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

Klaus
Posts: 9619
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Presenting images

Post by Klaus » Fri Dec 01, 2017 3:38 pm

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

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5464
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Presenting images

Post by FourthWorld » Fri Dec 01, 2017 6:19 pm

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.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

atrembla
Posts: 5
Joined: Thu Nov 30, 2017 10:53 pm

Re: Presenting images

Post by atrembla » Fri Dec 01, 2017 6:27 pm

Thank you so much for the tip!

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1969
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria
Contact:

Re: Presenting images

Post by richmond62 » Fri Dec 01, 2017 9:15 pm

It might be sensible to consider resizing the images to the size of the "image" on the card.

atrembla
Posts: 5
Joined: Thu Nov 30, 2017 10:53 pm

Re: Presenting images

Post by atrembla » Tue Dec 05, 2017 5:58 pm

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&""

Klaus
Posts: 9619
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Presenting images

Post by Klaus » Tue Dec 05, 2017 6:13 pm

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

atrembla
Posts: 5
Joined: Thu Nov 30, 2017 10:53 pm

Re: Presenting images

Post by atrembla » Wed Dec 06, 2017 3:27 pm

Thank you! This has been very helpful. Good catch – that variable was supposed to be one word (i.e., holdposition). 8)

Post Reply

Return to “Mac OS”