Export snapshot - is it usable on LiveCode web apps?

Mark Waddingham mark at livecode.com
Thu Aug 8 08:39:00 EDT 2024


On 2024-08-08 10:22, Jimmieson, Phil via use-livecode wrote:
> Hi folks,
> I’m experimenting with converting one of my LiveCode iPad Apps into a 
> web version, to see how well it works, but there’s an issue that seems 
> to be a deal-breaker. My iPad app takes a screenshot of the LiveCode 
> stack when the user navigates away from the main card, so that the 
> image can be used elsewhere in the app. This works fine on iPad, but I 
> noticed that the web version of the app generates a javascript 
> exception when I try to leave the main card. On checking the 
> dictionary, I noticed that the export snapshot command is not listed as 
> being supported on web. Is this correct? If so, is there an alternative 
> that will work for web?

So 'export snapshot from screen' is not supported - this is the form 
which takes the pixel data from the actual (composited) screen buffer.

However, there is an alternate form which is entirely internal to the 
engine:

    export snapshot from [ rect <rect> of ] <object>

To use the internal form for a card you can do:

    export snapshot from this card

Or if you want a portion of the card:

    export snapshot from rect 0,0,100,100 of this card

Further there is an `at size <width>,<height>` clause which allows you 
to specify the size you want the resulting image.

The difference here is that the internal form replicates the same 
process that the engine uses to render objects to a window - it renders 
the given rectangle of the object into a rect of the specified size (or 
the size of the rect/object if 'at size' is not specified).

In contrast, the 'external' form has to ask the OS for the given 
rectangle of the actual screen's framebuffer.

Hope this helps,

Mark.

-- 
Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
LiveCode: Build Amazing Things



More information about the use-livecode mailing list