Snapshot problems

Richard Gaskin ambassador at
Sun Sep 20 14:48:14 EDT 2009

Graham Samuel wrote:

 > However Richard your other point:
 >> The rect option can be useful at times, but since v2.7 we've had a
 >> much easier and more robust method of exporting images of objects
 >> by specifying the object itself rather than a rect:
 >>   import snapshot from img "MyImage"
 >> The object needn't be an image; it can be anything other than a stack
 >> (referencing the card will work for those), even groups.
 >> The big difference is how the image is generated:
 >> Using the rect option  cips a portion of the display buffer, so if
 >> your image is out of bounds there won't be anything to get.
 >> But using an object reference causes the engine to render the object
 >> into a private buffer for you, much like it would do when rendering
 >> the image on a card, and then hands that buffer back to you in the
 >> resulting image.
 > Is not so easy to follow if you're trying to build up a composite
 > image: say for the sake of argument one has a picture (an image)
 > occupying some part of a card, and one imposes on top of it another
 > image, with the intention of snapshotting the combined image so as to
 > create a new picture that can be exported: it might be a jpg of a
 > membership card with the member's picture imposed on it, or something
 > like that. Then if I import a snapshot of my background image (the
 > card design), won't  my foreground image (the member's picture) be
 > ignored? That's how I read the docs - so what I did in the end was to
 > use a rect based on the background image, something like:
 > import snapshot from rect (the rect of of img "MembershipCard")
 > This worked, but it appeared to me that I had to have a window (card,
 > stack) as big as the whole background image if nothing is to be
 > clipped, which was inconvenient.

If you can put the objects you want into a group, this needn't affect 
anything in your user experience and requires only small changes to your 
script, but would let you use the robust one-liner to get the snapshot 
of the group image even if outside of the clipping region of the window:

  import snapshot from grp "MyCompositeThang"

  Richard Gaskin
  Fourth World
  Revolution training and consulting:
  Webzine for Rev developers:

More information about the Use-livecode mailing list