On 2016-03-01 22:57, Terence Heaford wrote:
On 1 Mar 2016, at 21:32, J. Landman Gay <jac...@hyperactivesw.com> wrote:

"To export a snapshot for a portion of a stack you use the form:
export snapshot from rect[angle] of window windowID to ...
Where windowId is the windowId property of the required stack."

This does not work correctly on a Mac for the reason given previously.

The top and bottom of the image exported has shifted down by the depth
of the menubar.
put the rect widget "Chart" into tRect

export snapshot from rectangle tRect of window (the windowId of window
"Test") to tVar as PNG


The corrected version would be:

put the rect widget "Chart" into tRect

subtract 22 from item 2 of tRect

subtract 22 from item 4 of tRect

export snapshot from rectangle tRect of window (the windowId of window
 “Test") to tVar as PNG

There are three types of export/import snapshot.

The first uses the screen buffer - the co-ordinates have to be in screen co-ordinate space:

  export snapshot from rectangle tRect

The second uses the window buffer (if the OS has such things, otherwise it is equivalent to using the screen buffer after a translation of co-ordinates) - the co-ordinates have to be in window co-ordinate space (NOT card co-ordinate space):

  export snapshot from rectangle tRect of window tWindowId

The third uses no buffer at all, it asks the target object (and children) to render the specified rect of itself into an offscreen buffer (the same mechanism which the engine uses to update a window when the OS requests it, or a portion gets changed) - the co-ordinates have to be in card co-ordinate space:

  export snapshot from rectangle tRect of <object>

Now, the final form here will work for any object which is drawn by the LiveCode engine - it will not necessarily work for objects which use 'native' layers to display things (such as the browser). Whether or not one can get a native layer to render itself entirely depends on the native layer. For example, we've not had any success at all in persuading the CEF browser to give us a snapshot as it uses various 'native' things which do not want to give up their backing store of pixels.

Therefore, if you want to take a snapshot of a stack containing native layers your best bet to make this work generally is to use the screen or window form. When you do this you do have to take into account the fact that cards might have a vertical scroll due to menus (that mysterious 22 px) - you can get the current scroll amount by using 'the vscroll of stack ...'.

Warmest Regards,

Mark.

--
Mark Waddingham ~ m...@livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps

_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to