Snapshot problems

Graham Samuel livfoss at mac.com
Sun Sep 20 14:02:30 EDT 2009


Thanks to all who replied. I think my immediate problem was trying to  
get stuff from a rectangle that extended beyond the actual rendered  
area, as Richard mentions: this causes an 'Execution Error' with no  
further detail, so it's hard to know what has gone wrong - but finger  
trouble, essentially.

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.
>
> 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.
>
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.

Anyway I have cracked it, but I don't think the docs tell you all the  
ins and outs - and IMHO there aren't enough examples.

Thanks again

Graham




More information about the Use-livecode mailing list