Image control with dynamically associated image

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
AlessioForconi
Posts: 90
Joined: Sun Feb 15, 2015 2:51 pm

Image control with dynamically associated image

Post by AlessioForconi » Wed Nov 14, 2018 5:13 pm

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

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

Re: Image control with dynamically associated image

Post by Klaus » Wed Nov 14, 2018 5:57 pm

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

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Image control with dynamically associated image

Post by [-hh] » Wed Nov 14, 2018 6:33 pm

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"?
shiftLock happens

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

Re: Image control with dynamically associated image

Post by Klaus » Wed Nov 14, 2018 6:55 pm

Maybe? :D


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

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Image control with dynamically associated image

Post by jmburnod » Wed Nov 14, 2018 7:17 pm

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
https://alternatic.ch

AlessioForconi
Posts: 90
Joined: Sun Feb 15, 2015 2:51 pm

Re: Image control with dynamically associated image

Post by AlessioForconi » Wed Nov 14, 2018 7:34 pm

Thank you all for your help.
With the information you have provided me I will be able to do what I have in mind.

AlessioForconi
Posts: 90
Joined: Sun Feb 15, 2015 2:51 pm

Re: Image control with dynamically associated image

Post by AlessioForconi » Wed Nov 14, 2018 7:41 pm

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 ... ... ...

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”