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

Sannyasin Brahmanathaswami brahma at hindu.org
Wed Oct 28 07:04:17 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?

[coded]
  if (the width of tImage > the heigth of tImage )  then
      # portrait
      resizeToWidth tImage, 400
   else
      # 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?

How do we implement this, from the dictionary


The imageData, unlike the contents of the image<lcs,image,> container<lcs,container,>, is based on the picture as it's presented on the screen, not stored in the image<lcs,image,> object<lcs,object,glossary>. This means that if you resize an image<lcs,image,>, the content of the image<lcs,image,> does not change, but its imageData does. If you create an image<lcs,image,> and then reduce its size, its imageData reflects the scaled-down, displayed image<lcs,image,>, not the original full-scale image<lcs,image,>. If you create a second image<lcs,image,> and set its imageData property<lcs,property,> to the imageData of the original image<lcs,image,>, resizing the first image<lcs,image,> back to the original dimensions displays the original image<lcs,image,> at full resolution, but resizing the second image<lcs,image,> does not, because setting its imageData transferred only the scaled-down version of the original.


BR



More information about the use-livecode mailing list