making a thumbnail from a snapshot
Mark Schonewille
m.schonewille at economy-x-talk.com
Sun Feb 14 16:09:30 EST 2010
Hi Peter.
I use this function to create thumbnails:
function rescale theImgWidth,theImgHeight,theCdWidth,theCdHeight
-- determine longest side and rescale
if theCdWidth/theImgWidth < theCdHeight/theImgHeight then
put theCdWidth / theImgWidth into myRatio
else
put theCdHeight / theImgHeight into myRatio
end if
put theImgWidth * myRatio into myNewWidth
put theImgHeight * myRatio into myNewHeight
return myNewWidth,myNewHeight
end rescale
Usually, I have a background object, e.g. a rectangular graphic, in
which I want to fit a picture. I'd do this as follows.
lock screen
clone picture "Original"
set the name of it to "Thumb"
put rescale(the width of img "Thumb",the height of img "Thumb",the
width of grc "Back",the height of grc "Back") into myNewDimensions
set the width of img "Thumb" to item 1 of myNewDimensions
set the height of img "Thumb" to item 2 of myNewDimensions
set the loc of img "Thumb" to the loc of grc "Back"
unlock screen
--
Best regards,
Mark Schonewille
Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
Economy-x-Talk is always looking for new projects.
Op 14 feb 2010, om 00:03 heeft Peter Brigham MD het volgende geschreven:
> I'm trying to make a thumbnail from a snapshot of an image from
> another substack. First I clone a group that contains a thumbnail
> image and a text field, then I reposition the new group, then I try
> to get a new thumbnail into the new group. Here's what I've tried
> (partial script):
>
> clone group "imgItem 1"
> set the name of it to newGpName
> -- newGpName is already constructed, it is "imgItem k" for some k
> -- now set location of new group
> set the top of group newGpName to 30
> set the left of group newGpName to the left of group "imgItem 1"
> -- store the new rect of the thumbnail, then delete it
> put the rect of img "mThumb" of group newGpName into thumbRect
> delete img "mThumb" of group newGpName
> -- import new image into cloned group (last group)
> start editing group newGpName
> import snapshot from image "mDisplay" of stack "dispStack"
> -- rename image
> set the name of last image to "mThumb"
> stop editing background newGpName
> -- resize image to thumbnail size and location
> set the rect of img "mThumb" of group newGpName to thumbRect
>
> What I get is not a properly sized thumbnail -- I get an image that
> looks the size of the whole new (cloned) group, and it's not a
> miniature of the big image, it's a crop of the big image. I can't
> remember how to miniaturize an imported snapshot down to thumbnail
> size. I know this has been discussed before but can't find it in the
> gmane archives. Any help appreciated.
>
> -- Peter
>
> Peter M. Brigham
> pmbrig at gmail.com
> http://home.comcast.net/~pmbrig
>
More information about the use-livecode
mailing list