Scaling an Image to a Rect

Mark Wieder mwieder at ahsoftware.net
Tue Oct 15 23:52:46 CEST 2013


Dan Friedman <dan at ...> writes:

So, I thought I would ask this list for assistance since most of the
> people here are far smarter than I!

Well, I don't know about the smarter part, but here's what I do to generate
thumbnail images. It seems that you have the scaling options already worked
out, so I simplified this to just dealing with square images. I think what
you're missing is just locking the image and setting its text.


/**
 * ----------------------------------------
 * CreateThumbnail
 *
 * create a thumbnail image from the source image
 *
 * @pSourceImage : id of the image
 * @pNewWidth contains the width of the thumbnail image
 * @pNewHeight contains the height of the thumbnail image
 * ----------------------------------------
 */
function CreateThumbnail pSourceImage, pNewWidth, pNewHeight
   lock screen
   import snapshot from control id pSourceImage
   set the resizequality of the last image to "best"
   set the width of the last image to pNewWidth
   set the height of the last image to pNewHeight
   unlock screen
   return the id of the last image
end CreateThumbnail

on mouseUp
   local tTempImage
   
   -- create a 40x40 pixel thumbnail image from a square source image
   lock screen
   put CreateThumbnail(the id of image "image 1", 40, 40) into tTempImage
   set the width of image "image 2" to 40
   set the height of image "image 2" to 40
   set the lockloc of image "image 2" to true
   set the text of image "image 2" to the text of image id tTempImage
   delete image id tTempImage
   unlock screen
end mouseUp

-- 
 Mark Wieder
 mwieder at ahsoftware.net






More information about the use-livecode mailing list