image pasting

J. Landman Gay jacque at hyperactivesw.com
Tue Aug 19 22:47:00 EDT 2003


On 8/19/03 5:02 PM, Andrew wrote:

> Okay, I put this script into the Mouseup handler of a btn on my card, 
> and edited the script to say img "<name of my image>" instead of "1"
> However, it doesn't do anything when I click the button.  What gives?  :)

I broke down and actually tried it. I should have done that first. Some 
of what I wrote before is wrong.

The first pasted image creates a card-sized image object by default and 
pastes your image into it. No matter what the natural size of the image, 
it now takes up the whole card and its formattedwidth and 
formattedheight are the same as the card size. There's a lot of white 
space around it.

I used the "crop" command to remove the excess white space:

   crop image 1 to "100,100,200,200" -- use whatever rect you need

If you don't want to figure out a rect, you can place a transparent 
field or button over the image and resize it like a frame around the 
part you want to keep. Then you can use:

   crop image 1 to the rect of btn "frame"

This gave me a small image object with very little white space, 
containing only the actual picture content.

After that, every new paste operation always replaced the contents of 
the first image object, even if I changed tools in between. I couldn't 
create a second new object just by pasting. So I created one by script:

   create image
   paste

This gives me a second image object and the paste goes into that one. An 
interesting side effect is that the default size of the new second image 
is the same as the now-cropped image 1.

To control the size of a new image object, set the imageTemplate to 
whatever properties you need; for example:

   set the rect of the imageTemplate to "100,100,200,200"
   create image
   paste

That seems to do it.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com




More information about the use-livecode mailing list