Reposting from a thread in 2016

Tom Glod tom at makeshyft.com
Fri Aug 16 21:21:39 EDT 2019


Hey Folks I found this gem in a thread from 2016..... from Mark
Waddingham ... the thread helped me solve a problem with taking a
snapshot of a browser window.

Thanks Mark for taking the time to tell us about the inner workings of
the Engine.

--------------------------------------------------------------



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.



More information about the use-livecode mailing list