Page 1 of 1

Insert Image Into multiple Graphic

Posted: Fri Dec 06, 2013 7:49 pm
by marcelloe
I know how to put images into a graphic. This is what I want to do. I want to put an image into a graphic if the graphic is empty. If there is an image in the graphic go to the next graphic and put image there. I think it should be an else statement, but not sure how to script it. What I have tried doesn't work.

Thanks for your help

Mark

Re: Insert Image Into multiple Graphic

Posted: Mon Dec 09, 2013 11:26 am
by LCNeil
Hi Mark,

You are on the right lines with the if else statement :)

One of the easier ways to do this is to include placeholder image areas within your graphic areas. Then when importing your image you would do something like-

Code: Select all

put the last image into image “placeHolder1”
and then set the rect of this image to the rect of the graphic like previously shown in the import image example-

Code: Select all

set the rect of image “placeHolder1” to the rect of graphic “sign”
Then the next time you import an image you can check if the first placeholder is empty or not and then proceed appropriately-

Code: Select all

if image “placeHolder1” is not empty then
put the last image into image “placeHolder2”
set the rect of image “placeHolder2” to the rect of graphic “sign2”
else
put the last image into image “placeHolder1”
set the rect of image “placeHolder1” to the rect of graphic “sign”
end if
Kind Regards

Neil Roger
--
RunRev Support Team ~ http://www.runrev.com
LiveCode – Realize fast, compile-free coding

--

Re: Insert Image Into multiple Graphic

Posted: Mon Dec 09, 2013 5:02 pm
by marcelloe
This is the script I am trying to use. What am I doing wrong?

Code: Select all

 if the environment is "mobile" then
      mobilePickPhoto "camera"
      put the last image into image "placeHolder1"
      set the rect of image "placeHolder1" to the rect of graphic "video 1"
      if image "placeHolder1" is not empty then
         put the last image into image "placeHolder2"
         set the rect of image "placeHolder2" to the rect of graphic "video 2"
      else
         put the last image into image "placeHolder1"
         set the rect of image "placeHolder1" to the rect of graphic "video 1"
         end if
      end if

Re: Insert Image Into multiple Graphic

Posted: Mon Dec 09, 2013 5:14 pm
by LCNeil
Hi Mark,

Have you created image controls (Placeholder1 & Placeholder2) on your stack for the defined last images to go into?

Kind Regards

Neil Roger
--
RunRev Support Team ~ http://www.runrev.com
LiveCode – Realize fast, compile-free coding

--

Re: Insert Image Into multiple Graphic

Posted: Mon Dec 09, 2013 5:22 pm
by marcelloe
No, i was wondering about that. What kind of placeHolder does it need to be. Can I use a graphic? Do the placeHolders need to be on the same card or can i put them on a different card?

Re: Insert Image Into multiple Graphic

Posted: Mon Dec 09, 2013 5:34 pm
by LCNeil
Hi Mark,

Image and graphic objects are two separate entities in LiveCode. You can have a graphic on your stack (just like you have already), as a visual representation of where you would like and image placed but when dealing with images you must use an image object.

The placeholder must be image object and the easiest thing to do is make them the same dimensions as your existing rectangular graphics object.

You can create graphics object by dragging out the following highlighted tool from the tools pallet
Screen Shot 2013-12-09 at 16.31.52 copy.png
Kind Regards

Neil Roger
--
RunRev Support Team ~ http://www.runrev.com
LiveCode – Realize fast, compile-free coding

--

Re: Insert Image Into multiple Graphic

Posted: Mon Dec 09, 2013 5:58 pm
by marcelloe
Neil:

I just want to make sure I understand. I need to make 2 image areas for placeHolders. Then I can put the image from camera into the placeHolder and then Into the image area to display. Use the script that you have given me.

Questions:

1. can the placeHolder be on a different card?
2. The placeHolder will empty when the image is put into display area?
3. Do I need a script to look to see if there is currently an image in the display image?
4. Is there away to keep the images in place for the next time the app is used?

Re: Insert Image Into multiple Graphic

Posted: Tue Dec 10, 2013 10:21 am
by LCNeil
Hi Mark,

Please find attached an example of using the image placeholder method when importing images to your stack.

I have also included a check that will not allow you to import any more images to the stack if both image areas contain an image.

Please find below some answers to your additional queries-

1. can the placeHolder be on a different card?

Yes. You just need to reference the placeholder and card (e.g. put the last image into image "placeHolder1" of card "main"

2. The placeHolder will empty when the image is put into display area?

If you wish to empty the placeholder image you will need to use script e.g. put empty into image "placeHolder1"

3. Do I need a script to look to see if there is currently an image in the display image?

Yes. The method shown in the example and above is a way to check this (checking if the placeholder is empty or not)

4. Is there away to keep the images in place for the next time the app is used?

You will need to export your images to your library/documents and then re-open them when the app is opened (e.g. on the openCard/preOpenCard handler)

Kind Regards

Neil Roger
--
RunRev Support Team ~ http://www.runrev.com
LiveCode – Realize fast, compile-free coding

--

Re: Insert Image Into multiple Graphic

Posted: Tue Dec 10, 2013 4:57 pm
by marcelloe
Ok here is what I am stuck on. I am trying to use the following script to use 5 placeholders and 5 graphics. I can't seem to get the script to work. Also, when I try to use the camera on the 3rd picture the camera is just black.

Code: Select all

on mouseUp
   if image "placeHolder1"  is not empty and image "placeHolder2" is not empty  and image "placeHolder3" and image "placeHolder4" and image "placeHolder5" then
      exit mouseUp
   end if
   if the environment is "mobile" then
            mobilePickPhoto "camera"
            if image "placeHolder1" is not empty then
         put the last image into image "placeHolder2"
         delete the last image
         set the rect of image "placeHolder2" to the rect of graphic "video2"
            else
          put the last image into image "placeHolder1"
         delete the last image
         set the rect of image "placeHolder1" to the rect of graphic "video1"
            if image "placeHolder2" is not empty then
         put the last image into image "placeHolder3"
         delete the last image
         set the rect of image "placeHolder3" to the rect of graphic "video3"
            else
          put the last image into image "placeHolder2"
         delete the last image
         set the rect of image "placeHolder2" to the rect of graphic "video2"
               end if
         end if
end mouseUp

Re: Insert Image Into multiple Graphic

Posted: Wed Dec 11, 2013 2:29 pm
by LCNeil
Hi Mark,

I will also go over this is todays webinar

Kind Regards

Neil Roger
--
RunRev Support Team ~ http://www.runrev.com
LiveCode – Realize fast, compile-free coding


Re: Insert Image Into multiple Graphic

Posted: Thu Dec 12, 2013 5:01 pm
by marcelloe
Neil:

I am having issues with using the script from the webinar in my stack. The images don't go into the designated area. It takes up the whole screen. What am I doing wrong? I will email you my stack to look at.

Thanks

Mark

Re: Insert Image Into multiple Graphic

Posted: Fri Dec 13, 2013 11:25 am
by LCNeil
Hi Mark,

I have emailed your stack back to you

Kind Regards

Neil Roger
--
RunRev Support Team ~ http://www.runrev.com
LiveCode – Realize fast, compile-free coding

--