dump newbie image questiosn

Cubist at aol.com Cubist at aol.com
Mon Jun 6 16:57:24 EDT 2005


sez jbondy at sover.net:
>J. Landman Gay wrote:
>> No, I wasn't joking. I'm not even sure I understand the problem 
>> because I've never seen it. I always scale images by calculating the
>> desired dimensions and setting the image to that size. For example, if
>> I want an image to display at 1/3 its natural size, I do this:
>> set the width of img 1 to round((the formattedwidth of img 1) * .3)
>> set the height of img 1 to round((the formattedheight of img 1) * .3)
>This is great if you know in advance that there is enough room to 
>display the image in this way, at this particular scale.  What I wanted
>was something that automatically displayed the image at the largest 
>resolution possible in "the available space".  That's where the 
>confusion comes in: I need to store the "available space" somewhere in
>the Image object if I am to perform the computations properly.  Maybe it
>is just that simple, at least for me.
   You want to know what factor an image should be resized by in order to fit 
into your viewer? Not a problem. Presumably, you know how much space your 
image-viewer *has* in which to display your image -- if you don't, I suspect 
you're pretty well screwed until the good folk at RunRev come out with code for 
the justDoItForCryingOutLoud handler. So, given the known dimensions of the 
viewable area, something along these lines might be appropriate:

function FindResizeFactor ViewX, ViewY, ImageX, ImageY
    return min (ViewX/ImageX,ViewY/ImageY)
end FindResizeFactor


More information about the use-livecode mailing list