Insert Image Into multiple Graphic

Moderators: LCNeil, heatherlaine, kevinmiller, elanorb

Post Reply
marcelloe
Posts: 140
Joined: Thu Oct 17, 2013 2:26 pm

Insert Image Into multiple Graphic

Post by marcelloe » Fri Dec 06, 2013 7:49 pm

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

LCNeil
Livecode Staff Member
Livecode Staff Member
Posts: 1223
Joined: Wed Oct 03, 2012 4:07 pm

Re: Insert Image Into multiple Graphic

Post by LCNeil » Mon Dec 09, 2013 11:26 am

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

--

marcelloe
Posts: 140
Joined: Thu Oct 17, 2013 2:26 pm

Re: Insert Image Into multiple Graphic

Post by marcelloe » Mon Dec 09, 2013 5:02 pm

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

LCNeil
Livecode Staff Member
Livecode Staff Member
Posts: 1223
Joined: Wed Oct 03, 2012 4:07 pm

Re: Insert Image Into multiple Graphic

Post by LCNeil » Mon Dec 09, 2013 5:14 pm

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

--

marcelloe
Posts: 140
Joined: Thu Oct 17, 2013 2:26 pm

Re: Insert Image Into multiple Graphic

Post by marcelloe » Mon Dec 09, 2013 5:22 pm

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?

LCNeil
Livecode Staff Member
Livecode Staff Member
Posts: 1223
Joined: Wed Oct 03, 2012 4:07 pm

Re: Insert Image Into multiple Graphic

Post by LCNeil » Mon Dec 09, 2013 5:34 pm

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

--

marcelloe
Posts: 140
Joined: Thu Oct 17, 2013 2:26 pm

Re: Insert Image Into multiple Graphic

Post by marcelloe » Mon Dec 09, 2013 5:58 pm

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?

LCNeil
Livecode Staff Member
Livecode Staff Member
Posts: 1223
Joined: Wed Oct 03, 2012 4:07 pm

Re: Insert Image Into multiple Graphic

Post by LCNeil » Tue Dec 10, 2013 10:21 am

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

--
Attachments
Multiple Image Import.zip
(3.05 KiB) Downloaded 188 times

marcelloe
Posts: 140
Joined: Thu Oct 17, 2013 2:26 pm

Re: Insert Image Into multiple Graphic

Post by marcelloe » Tue Dec 10, 2013 4:57 pm

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

LCNeil
Livecode Staff Member
Livecode Staff Member
Posts: 1223
Joined: Wed Oct 03, 2012 4:07 pm

Re: Insert Image Into multiple Graphic

Post by LCNeil » Wed Dec 11, 2013 2:29 pm

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


marcelloe
Posts: 140
Joined: Thu Oct 17, 2013 2:26 pm

Re: Insert Image Into multiple Graphic

Post by marcelloe » Thu Dec 12, 2013 5:01 pm

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

LCNeil
Livecode Staff Member
Livecode Staff Member
Posts: 1223
Joined: Wed Oct 03, 2012 4:07 pm

Re: Insert Image Into multiple Graphic

Post by LCNeil » Fri Dec 13, 2013 11:25 am

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

--

Post Reply

Return to “idea2app and Coding School”