Saving snapshots to files

Wilhelm Sanke sanke at hrz.uni-kassel.de
Thu Mar 11 15:51:46 EST 2004


OnThu, 11 Mar 2004, Ken Norris <pixelbird at interisland.net> wrote:

> Sorry to ask this ahead of scriptwriting, but for the moment I'm running
> scared of crashes, plusI want to do some planning before I attack.
> (snip)
> 2) Here's the part I need help with: Change venues. Rather than have the
> snapshots embedded in a substack (I don't want an extra window to 
> appear), I
> want to save the image files to a folder and have sorted index lists call
> them into a card for printing.
> (snip)
> How do I send imported snapshots to a file? How do I call them back? What
> kind of images are imported snapshots?
>
> May I please get some scripting ideas and suggestions? Is there perhaps a
> template somewhere?
>
> TIA,
> Ken N.  


Hi Ken,

As the documentation says you can export snapshots as jpegs, pngs, 
(gifs), and "paints".

You could automate the assigning of file names for the images to 
retrieve them later from a folder and then to set the filename of a 
placeholder image in a stack to any image in the folder.

Here are two scripts from one of my stacks that you could modify and 
that address the exporting part.
In this case the user is asked to provide a filename, but this indeed 
could be automated.

Button "take snapshot"

on mouseUp
lock screen
  put the windowID of this stack into StackID
   import snapshot from rect 197,145,1097,820 of window StackID
   choose browse tool
   set the rect of last image to 197,145,1097,820 # so the snapshot will 
not be visible as such
   unlock screen # withouth "unlock" at this place there will be an 
error message
   send "mouseup" to btn "export"
 end mouseUp}


Button "Export"

on mouseUp
  ask file "Choose a file name (extension .jpg will be added)" with 
filter "*.jpg"
  put it into LongDateiName
   if LongDateiName is not empty then
     put the number of chars of LongDateiName into Laenge
    repeat with i =Laenge down to 1
      put char i of longDateiName into SChar
       if SChar is "/" then
         put i into LastSlash
        exit repeat
       end if
   end repeat
     put char (LastSlash + 1) to Laenge of LongDateiName into Dateiname
    put char 1 to (LastSlash - 1) of LongDateiName into NewDirectory
    set the directory to NewDirectory
     put Dateiname&".jpg"  into Dateiname
    select last image
     export jpeg to file Dateiname
    delete last image
   else
     exit to top
   end if
 end mouseUp




More information about the use-livecode mailing list