LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!
The "from rect" form works quite well, but I was intrested in implementing the "of object" form... only my script never seams to compile.
I just want to take a screenshot of my main stack window, whatever size it is and where ever it is on the screen...
export snapshot of window (the mainstack of this stack) to file pictPath as PNG
export snapshot of stack (the mainstack of this stack) to file pictPath as PNG
export snapshot from rect (the rect of this card) of window (the windowid of this stack) to file "myimage.png" as png
With stack, the syntax is as folllows. The coordinates are then relative to the screen rectangle. Any window that overlaps with the snapshot will be included in the snapshot.
With the latest 2.8 I've had problems exporting snapshots when the rectangle was of a certain size and located on my second screen. It would cause an execution error : (
go card"Grafico" of stack"Grafico"
export snapshot from rect (the rect of this card) of window (the windowid of this stack) to file "Grafico.jpg" as jpeg
Hi Alessandro,
Allow me to reply here, as this may be of interest to others. The problem is possibly that the snapshot is being taken before the card content is fully loaded.
You may want to add wait 10 tick (or whatever works) before export snapshot. Something else to try is to use a dummy instruction that requires access to all controls on the cards, like put the number of controls of this card into myVar.
alessandropisoni wrote:Problem resolved in part. Inserting a answer box before export snapshot the image it comes saved correctly!
Thanks for these additional information. Answer box... then this reminds me of a similar problem I got a while ago. With an answer box, I could get the screen refreshed in time for the snapshot. Without the answer box, the snapshot was taken before the screen got refreshed.
Using anything else, like wait for 10 ticks or whatever other on screen event didn't work. Only the answer box made the trick.
Because an answer box was not appropriate in the application, I completely reorganized my code to have the behavior I wanted. I couldn't understand however the source of the problem (not enough to enter a bug). Do you have a short demo stack associated with this you could make available?
Also to a my friend who develops in Revolution it succeeds the same
thing and it must force the program with a answer box! How never
nobody has informed the producers of the software of this anomaly? It
would be comfortable to have a commando tipo"Refresh card"!!!
I have found an other problem with exportsnapshot under windows.
Putting answer box before the command export the image that saves it
has over the answer box. In practical it does not wait for that I
confirmations the box but execute of continuation the instruction
export. This only with windows with Mac the image comes exported
after that I have to confermed the key in the answer box.
export snapshot from rect (the rect of this card) of window (the windowid of this stack) to file "Grafico.jpg" as jpeg
What is the syntax if I wish to print part of the card? For example:
1. from left co-ordinate (x1, y1) of this card to the rest of this card
2. from left co-ordinate (x1, y1) of this card to the right co-ordinate (x2, y2) of this card