Shrinking an image to a button icon

Jim Carwardine JimCarwardine at OwnYourFuture-net.com
Mon Dec 22 15:26:42 CST 2003


I got that button icon to work, now I want to show the original picture in a
floating palette that the user can move around.  I chose the palette format
so they can navigate to different stacks and the picture will still float
with them.  Is the palette a good strategy for that?

I'm still controlling the size of the picture, but I want to show a larger
one as an option.  Here's the script.  I can't seem to get the stack window
to exactly frame the picture.  Should I be changing the card rect?...

go stack "Picture"
    put 300 into theTargetSize -- adjust size here
    create image
    set the filename of last img to the pictPath of me
    put theTargetSize/the formattedwidth of last img into theRatio
    set the width of last img to theTargetSize
    set the height of last img to \
        round(the formattedheight of last img * theRatio)
    get the rect of last img
    set the rect of stack "Picture" to it
    palette stack "Picture"

Jim

on 12/21/03 10:52 PM, J. Landman Gay wrote:

> On 12/21/03 7:49 PM, Jim Carwardine wrote:
> 
>> Does anyone have scripting to take an image selected by the user, shrink it
>> to a thumbnail and place it as an icon on a button?  When the button is
>> clicked, I¹d like to show the picture snapshot size... Jim
> 
> In the script of the display button:
> 
> on mouseUp
>  answer file "Choose image:"
>  if it = "" then exit mouseup
>  put it into theImgPath
>  put 75 into theTargetSize -- adjust size here
>  create image
>  hide last img -- you may want to change this
>  set the filename of last img to theImgPath
>  put theTargetSize/the formattedwidth of last img into theRatio
>  set the width of last img to theTargetSize
>  set the height of last img to \
>      round(the formattedheight of last img * theRatio)
>  set the icon of me to the short id of last img -- or set a different btn
>  choose browse tool
> end mouseUp

-- 

OYF is... Highly resourceful people working together.
<http://www.OwnYourFuture-net.com>

Own Your Future Consulting Services Limited,
1959 Upper Water Street, Suite 407, Halifax, Nova Scotia. B3J 3N2
Info Line: 902-823-2477, Phone: 902-823-2339. Fax: 902-823-2139





More information about the use-livecode mailing list