Snapshot problems

Richard Gaskin ambassador at fourthworld.com
Sat Sep 19 15:17:40 EDT 2009


Graham Samuel wrote:
> I suppose it's just finger trouble, but I'm having great difficulty  
> using import snapshot and export snapshot - the RunRev docs seem not  
> to be completely specific on this. For example, while apparently I can  
> take a snapshot of something that isn't open and isn't visible (the  
> docs say so!), I don't seem to be able to take a snapshot of an object  
> whose loc is outside the visible area. For example I have an image  
> which I've placed out of site at 2000,2000 based on a quite small  
> stack, say 800 by 600 pixels. I'm used to this technique for hiding  
> stuff from the user, and also for working with objects larger than the  
> visible area - in this case, I am doing both of these. Now I want to  
> tinker with the image. The statement
> 
> import snapshot from rect 1375,2592,1749,2625 of this stack
> 
> compiles OK but results in an execution error. Experiments seem to  
> show that a statement of the same form restricted to the bounds of the  
> stack's window work OK.
> 
> What I'm actually trying to do is to create a composite image at  
> screen resolution, by overlaying images on top of one another and then  
> taking a snapshot of the resultant screen area, but all without the  
> user seeing anything. My experiments appear to show that I can do it  
> while the various objects are visible (in the visible area) but not  
> otherwise. Can anyone explain how this could be done?

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.

In my experience using object references is reliable under a much wider 
range of circumstances than using rects, even with objects on cards that 
aren't open.

This extension to the snapshot syntax was a by-product of the massive 
rendering overhaul Mark Waddingham did for v2.7, and one that's done 
wonders here for making screenshots very easily.

--
  Richard Gaskin
  Fourth World
  Revolution training and consulting: http://www.fourthworld.com
  Webzine for Rev developers: http://www.revjournal.com



More information about the use-livecode mailing list