Scaling an Image to a Rect
admin at FlexibleLearning.com
Wed Oct 16 00:12:08 EDT 2013
Depends if you mind 'losing the cropped data' or not.
An alternative to Richard's elegant snapshot solution, which would lose the
cropped data, is a fixed location group where the resized image's width or
height fits the group width or height. Any excess image is not lost, simply
not visible. Also means you can use your existing proportional width/height
From: Richard Gaskin <ambassador at fourthworld.com>
To: use-livecode at lists.runrev.com
Sent: Tue, 15 Oct 2013 16:00:43 -0700
Subject: Re: Scaling an Image to a Rect
You probably already know this, but in order to make the new Project
Browser the RunRev team added the ability to create thumbnails from the
import and export commands with the addition of "at" args:
import snapshot [from rect[angle] rectangle] [of object]
[(with | without) effects] [at size width, height]
You still need to calculate the desired width and height, but the time
saved by letting the engine do this on the image buffer internally
rather than resizing an image and re-setting its contents is pretty amazing.
From: Dan Friedman <dan at clearvisiontech.com>
To: use-livecode <use-livecode at lists.runrev.com>
Sent: Tue, Oct 15, 2013 4:11 pm
Subject: Scaling an Image to a Rect
I have been piddling around with this for weeks and still can't get it
kinda got it working... but it's still not always 100% correct. So, I
would ask this list for assistance since most of the people here are far
You have a rect and an image. The goal is to completely fill the rect with
image. But, we don't want to distort the image. So, you need to
scale the image up (if the image is smaller than the rect) or down (if the
is larger than the rect). Remember that we want to completely fill rect.
ok (and expected) that some of the image will be cropped.
Think of this as setting the background of a stack with an image. You want
fill the entire background of the stack (regardless of the size of the
with the image (regardless of the rect of the image). But we don't want to
distort the image.
More information about the use-livecode