Dealing with a picture
J. Landman Gay
jacque at hyperactivesw.com
Mon Nov 22 21:26:52 CST 2010
On 11/22/10 9:58 AM, Scott Pepperdine wrote:
> I want to import an picture onto a card,
> re-size the picture to about 2"x2", the size I want when I eventually
> print it.
> Save it to a sub directory, and change the source of the image object on
> the card
> By placing the picture in a sub directory, I hope to avoid loading into
> memory all the pictures on all the cards in the stack when I open the
> I've got the 'answer file' part working, but have no clue what to do next.
> Please point me to a tutorial or if not, tell me what commands I'll need
> to use.
A locked image object will scale whatever file you put into it so that
the image fits the size of the image object. That means what you want to
do is pretty easy. Create an empty image object, size it on the card the
way you want it, and then set the lockLoc of the image to true. Now
whatever image file you set it to will scale to fit the image object.
Then use your answer file command to get the filepath and set the
filename of the image to that path:
answer file "Choose an image:"
if it is empty then exit to top
set the filename of image "myImage" to it
Bingo, auto-scale. But be warned -- if your image object is a square and
the user chooses a non-square image file, it will be distorted when it
resizes to fit into a square. If that's not what you want then you need
to do some calculations and resize your image object dynamically so it's
proportional to the image it will hold.
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
More information about the use-livecode