Scaling Imported Images

Bob Sneidar bobsneidar at iotecdigital.com
Tue Aug 20 10:27:41 EDT 2019


Thanks! You'd think that was in the dictionary somewhere, but I searched for scale and got bupkis. 

Bob S


> On Aug 20, 2019, at 04:01 , hh via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
>> Bob S. wrote:
>> I seem to remember some time ago there was a key combination
>> so that when you sized an image, instead of cropping it, it
>> would scale it. Am I imagining things? I can create a new
>> scaled image in Preview, so no big deal. 
> 
> Resizing with the pointer tool has these modifier specials:
> 
> use with shift  => resizes proportional
> use with option => resizes to square
> use with mac-cmd/win-nux-ctrl => crops
> 
> Posssibly this is not what you want, because this operation only
> changes the display, not the size of the original imported image.
> So the size of the image in the stack is always the same.
> 
> To make the *new size* to be 'persistent', that is
> new width => formattedWidth and new height => formattedHeight
> use
> 
> set imagedata of img imgName to the imagedata of img imgName
> 
> Here is the complete script I use for scale or fit incl. the above.
> 
> -- pRetain is true or false (=persistence of new size)
> -- pImgID is the long id of an image
> -- pHow is one of f[actor],w[idth],h[eight],l[arger],s[maller],?
> -- pVal is a positive Number
> on scaleOrFitImage pRetain,pImgID,pHow,pVal
>  lock screen; lock messages
>  put the formattedWidth of pImgID into w
>  put the formattedHeight of pImgID into h
>  switch char 1 of pHow
>    case "f" -- scale with factor pVal
>      put pVal*w into w0
>      put pVal*h into h0
>      break
>    case "w" -- fit width to pVal
>      put pVal*h/w into h0
>      put pVal into w0
>      break
>    case "h" -- fit height to pVal
>      put pVal*w/h into w0
>      put pVal into h0
>      break
>    case "l" -- fit max(width,height) to pVal
>      if h > w then -- fit height to pVal
>        put pVal*w/h into w0
>        put pVal into h0
>      else -- fit width to pVal
>        put pVal*h/w into h0
>        put pVal into w0
>      end if
>      break
>    case "s" -- fit min(width,height) to pVal
>      if h < w then -- fit height to pVal
>        put pVal*w/h into w0
>        put pVal into h0
>      else -- fit width to pVal
>        put pVal*h/w into h0
>        put pVal into w0
>      end if
>      break
>    default -- current width and height
>      put the width of pImgID into w0
>      put the height of pImgID into h0
>      break
>  end switch
>  put the topleft of pImgID into TL
>  set width of pImgID to w0
>  set height of pImgID to h0
>  set topleft of pImgID to TL
>  if pRetain then
>    # width => formattedWidth and height => formattedHeight
>    set imagedata of pImgID to the imagedata of pImgID
>  end if
> end scaleOrFitImage
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list