New to Get a Copy of Scaled Down Version of an Image

Sannyasin Brahmanathaswami brahma at
Wed Oct 28 06:28:18 EDT 2020

Take for example

[command] resizeToWidth tImage, 400

on resizeToWidth pImage,pSize
   local tOrigImgWidth, tOrigImgHeight, tRatio, tNewWidth, tNewHeight
   set the itemdel to "x"
   put item 1 of sCurrentGraphicRect into tOrigImgWidth
   put item 2 of sCurrentGraphicRect into tOrigImgHeight

   if tOrigImgWidth is 0 then exit resizeToWidth

   put pSize/tOrigImgWidth into tRatio
   put (tOrigImgHeight * tRatio) into tNewHeight
   put (tOrigImgWidth * tRatio) into  tNewWidth

   set the rect of  pImage to 0,0,tNewWidth,tNewHeight

end resizeToWidth

How do I get a copy, with the image scaled down, which is visible on screen?

  if (the width of tImage > the heigth of tImage )  then
      # portrait
      resizeToWidth tImage, 400
      # landscape
      resizeToHeigth tImage, 400
   end if

   # now we set the img to the img "currentpuzzle"
   set the name of the last image to "currentpuzzle"

   # and copy the data, at 400px wide
   put the rect of the last image into tImageData["rect"]
   put the imageData of the last image into tImageData["image"]

   put tImageData["image"] into image "currentpuzzle"

   BUT the full scaled copy of the image "currentpuzzle" comes into view. I wanted to get a scaled down version?

Svasti Astu – Be Well

Get – It free!

More information about the use-livecode mailing list