Page 1 of 1

Image control with dynamically associated image

Posted: Wed Nov 14, 2018 5:13 pm
by AlessioForconi
Hello everyone.

I do not know if it can be done, but I would like to set it dynamically depending on some criteria.

I already imported the images into the stack and automatically livecode created as many image controls as the imported images.

What I would like to understand is:

1 - Can I import images into the stack without creating an image control for each of them?

2 - Can I use a single image control to associate the image that matches the criteria I provide?

Thank you

Re: Image control with dynamically associated image

Posted: Wed Nov 14, 2018 5:57 pm
by Klaus
Buonasera Allessio,
1 - Can I import images into the stack without creating an image control for each of them?
no, once an image is in LC it becomes an image object.
2 - Can I use a single image control to associate the image that matches the criteria I provide?
Yes, sure, you can always do something like -> put img 1 into img 2

But I would recommend to use a button object where you just set the ICON to the id of an image you want to display, no need for fiddling around with putting images into images etc. :D

Best

Klaus

Re: Image control with dynamically associated image

Posted: Wed Nov 14, 2018 6:33 pm
by [-hh]
Klaus wrote:no, once an image is in LC it becomes an image object.
Klaus,
he possibly wants to load images from file into a variable or custom property and then set from there the text of img "onlyimage"?

Re: Image control with dynamically associated image

Posted: Wed Nov 14, 2018 6:55 pm
by Klaus
Maybe? :D


Your message contains 9 characters.
You need to enter at least 10 characters.

Re: Image control with dynamically associated image

Posted: Wed Nov 14, 2018 7:17 pm
by jmburnod
Hi Alessio,
You can also use filename to display an image.
This script get a llist of imgs in a folder and display them in one image with a wait time between each image.You can also use filename to display an image.
This script get a llist of imgs in a folder and display them in one image with a wait time between each image.
Image proportional resizing will be probably the next step

Code: Select all

on debChooseFolder
   answer folder "Choose a folder"
   if it = empty then exit debChooseFolder
   put it into tPathFol
   put getImgFiles(tPathFol) into tAllPathImg
   repeat for each line tPathImg in tAllPathImg
      put tPathFol & "/"  & tPathImg into tPathFile
      set the filename of img 1 to tPathFile
      wait 300 milliseconds
   end repeat
end debChooseFolder

function getImgFiles pPathFol -- return a list of imgs .png and .jpg in a folder
   put ".png,.jpg" into tTheExt
   set the folder to pPathFol
   put the files into tFiles
   put empty into rgetImgFiles
   repeat for each line tPath in tFiles
      if char -4 to -1 of tPath is in tTheExt then
         put tPath & cr after rgetImgFiles
      end if
   end repeat
   delete char -1 of rgetImgFiles
   return rgetImgFiles
end getImgFiles
Best regards
Jean-Marc

Re: Image control with dynamically associated image

Posted: Wed Nov 14, 2018 7:34 pm
by AlessioForconi
Thank you all for your help.
With the information you have provided me I will be able to do what I have in mind.

Re: Image control with dynamically associated image

Posted: Wed Nov 14, 2018 7:41 pm
by AlessioForconi
Mm ... what I do not do is extract the name of iimagine as I flow through the cycle for each.

The image name will be the criterion for choosing or discarding it.

The names of the images are 1.png 2.png 3.png ... ... ...