Fun with the templateimage
Richard Gaskin
ambassador at fourthworld.com
Thu Oct 31 12:36:09 EDT 2019
The "import snapshot" command had an "at size" option added several
versions ago to facilitate some scaling tasks:
import snapshot from the selectedObject at size 100,100
But oddly, no such option has been added to the "export snapshot" command.
--
Richard Gaskin
Fourth World Systems
Bob Sneidar wrote:
> Or better yet: -- No error checking, assumes parameters are correct. Also not tested. :-)
>
> on exportScaledImage pSourceFile, pDestFile, pScaleFactor, pFormat
> ## My good ol' banana, older users of MC might remember that one :-D
> set the filename of the templateimage to pSourceFile
>
> ## This was a know (to me) feature
> put the formattedwidth of the templateimage into tFW
> put the formattedheight of the templateimage into tFH
> ## Now you can apply some "rule of three" to scale the image while preserving its ratio
> ## I'll leave that up to you... :-)
>
> ## I cheated a bit:
> set the width of the templateimage to round(tFW * (pScaleFactor /100))
> set the height of the templateimage to round(tFH * (pScaleFactor /100))
>
> ## But this one really suprised me:
> switch pFormat
> case "JPEG"
> export the templateimage to file (pDestFile) as JPEG
> break
> case "BMP"
> export the templateimage to file (pDestFile) as BMP
> break
> case "PNG"
> export the templateimage to file (pDestFile) as PNG
> break
> end switch
>
> reset the templateimage
> end exportScaledImage
More information about the use-livecode
mailing list