Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
RCozens
- Posts: 138
- Joined: Thu Aug 05, 2021 6:42 am
- Location: Manchester, CA USA
Post
by RCozens » Mon Sep 27, 2021 5:36 pm
jacque wrote: ↑Mon Sep 27, 2021 7:10 am
BTW, the "of this card" isn't necessary. Object references are only needed if you want the whole object snapshotted. (And cards aren't objects, really.)
Code: Select all
export snapshot from rectangle snapshotRectangle to image id imageIdNumber
Hi Jacque,
This is not clear to me from the LiveCode dictionary:
If a window, stack or object is specified, the rectangle is given in relative (window) coordinates; otherwise, it is given in absolute coordinates.
I'm not specifying the image in the command, so I presumed I needed "of this card" to have the command interpret the coordinates as relative rather than absolute.
Cheers!
Rob Cozens dba Serendipity Software Company
Manchester, CA USA
Each new generation gives more attention to the man-made world...
and less attention to the world that made man.
-
jacque
- VIP Livecode Opensource Backer
- Posts: 7237
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
-
Contact:
Post
by jacque » Mon Sep 27, 2021 5:43 pm
I forgot about that, you may be right. Since it doesn't seem to interfere with the other image formats you probably are right.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
-
RCozens
- Posts: 138
- Joined: Thu Aug 05, 2021 6:42 am
- Location: Manchester, CA USA
Post
by RCozens » Mon Sep 27, 2021 7:42 pm
RCozens wrote: ↑Sun Sep 26, 2021 7:10 pm
I want my code to read like a book.
But not always....I'm a bit of a hypocrite here:
If I want to initialize a boolean variable based on the state of the right mouse button previously stored in mouse3State, I script
Code: Select all
put (mouse3State is "down") into maskImage
not
Code: Select all
if mouse3State is "down" then put true into maskImage else put false into maskImage
Rob Cozens dba Serendipity Software Company
Manchester, CA USA
Each new generation gives more attention to the man-made world...
and less attention to the world that made man.
-
RCozens
- Posts: 138
- Joined: Thu Aug 05, 2021 6:42 am
- Location: Manchester, CA USA
Post
by RCozens » Mon Sep 27, 2021 7:45 pm
Yes, Jacque, "of this card" is required in the form of the export snapshot command I am using.
Without it I get a picture of a different portion of the monitor.
Rob Cozens dba Serendipity Software Company
Manchester, CA USA
Each new generation gives more attention to the man-made world...
and less attention to the world that made man.
-
RCozens
- Posts: 138
- Joined: Thu Aug 05, 2021 6:42 am
- Location: Manchester, CA USA
Post
by RCozens » Tue Sep 28, 2021 5:26 pm
Morning Panos,
The result sounds the same, but the bug report focuses on "export snapshot from image ..." which has been fixed according to Richmond.
My issue results from "export snapshot from rectangle ...". My guess is it's the same issue but the bug fix only corrected it in "export from image". Since "export from image" looks only at the specified image and disregards any other objects in the rectangle, while "export from rectangle" looks at all the pixels in the rectangle, it seems reasonable to believe the fix for one would not necessarily fix both.
I'm running v9.6.2 on a 64 bit Windows platform>
Cheers!
Rob Cozens dba Serendipity Software Company
Manchester, CA USA
Each new generation gives more attention to the man-made world...
and less attention to the world that made man.
-
richmond62
- Livecode Opensource Backer
- Posts: 9387
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Post
by richmond62 » Tue Sep 28, 2021 5:28 pm
As far as I recall that bug was fixed in 9.6.3 so it might not
be a bad idea to run that version and see if it still persists.
-
richmond62
- Livecode Opensource Backer
- Posts: 9387
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Post
by richmond62 » Tue Sep 28, 2021 5:49 pm
ALSO, got out my bucket and spade again:
-
- RectXP.png (21.17 KiB) Viewed 4513 times
-
-
Code: Select all
on mouseUp
export snapshot from rect 300, 200, 500, 400 of card "KARD" to file "RectXP.png" as PNG
end mouseUp
(MacOS 12 beta 7)
Why not download my stack and export on Windows and see what happens.
-
Attachments
-
- Xport from rect.livecode.zip
- Here's the stack.
- (130.58 KiB) Downloaded 113 times
-
RCozens
- Posts: 138
- Joined: Thu Aug 05, 2021 6:42 am
- Location: Manchester, CA USA
Post
by RCozens » Tue Sep 28, 2021 6:26 pm
richmond62 wrote: ↑Tue Sep 28, 2021 5:49 pm
-
Code: Select all
on mouseUp
export snapshot from rect 300, 200, 500, 400 of card "KARD" to file "RectXP.png" as PNG
end mouseUp
(
Thanks for your efforts. Try exporting as GIF and let me know what you get.
Rob Cozens dba Serendipity Software Company
Manchester, CA USA
Each new generation gives more attention to the man-made world...
and less attention to the world that made man.
-
richmond62
- Livecode Opensource Backer
- Posts: 9387
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Post
by richmond62 » Tue Sep 28, 2021 6:32 pm
Code: Select all
on mouseUp
export snapshot from rect 300, 200, 500, 400 of card "KARD" to file "RectXP.gif" as GIF
end mouseUp
-
- RectXP.gif (9.14 KiB) Viewed 4501 times
-
as expected.
LC 9.6.5 RC-1
-
RCozens
- Posts: 138
- Joined: Thu Aug 05, 2021 6:42 am
- Location: Manchester, CA USA
Post
by RCozens » Tue Sep 28, 2021 6:50 pm
RCozens wrote: ↑Sun Sep 26, 2021 7:10 pm
Code: Select all
put ["GIF"/"PNG"/"PMB"/"paint"] into imageType
export snapshot from rectangle snapshotRectangle of this card to image id imageIdNumber as imageType
I recognize in retrospect that I should not have identified the first line as actual code. In doing so I obscured my actual query.
In the following example the Script Editor will flag the first two of the three export commands as syntax errors and will not compile:
Code: Select all
put "GIF" into imageType
export snapshot from rectangle snapshotRectangle of this card to image id imageIdNumber as imageType
export snapshot from rectangle snapshotRectangle of this card to image id imageIdNumber as "GIF"
export snapshot from rectangle snapshotRectangle of this card to image id imageIdNumber as GIF
Since LiveCode allows so many references to be resolved at runtime, I have to wonder whether this syntax is not supported because of an oversight or because of something intrinsic in the Script Editor or the export snapshot command.
I would prefer to resolve image type at runtime rather than script a four-case switch.
Rob Cozens dba Serendipity Software Company
Manchester, CA USA
Each new generation gives more attention to the man-made world...
and less attention to the world that made man.
-
Klaus
- Posts: 13829
- Joined: Sat Apr 08, 2006 8:41 am
- Location: Germany
-
Contact:
Post
by Klaus » Tue Sep 28, 2021 6:53 pm
In the first two lines you try to use the STRING "Gif" as the format, but obviously LC does not like that.
-
RCozens
- Posts: 138
- Joined: Thu Aug 05, 2021 6:42 am
- Location: Manchester, CA USA
Post
by RCozens » Tue Sep 28, 2021 7:04 pm
richmond62 wrote: ↑Tue Sep 28, 2021 6:32 pm
Code: Select all
on mouseUp
export snapshot from rect 300, 200, 500, 400 of card "KARD" to file "RectXP.gif" as GIF
end mouseUp
-
RectXP.gif
-
as expected.
LC 9.6.5 RC-1
OK the mystery deepens.
Would you please create a new image the size of your rectangle and exporting to it instead of a file, or including multiple images in the rect?
If both of those work, I will have to dig deeper.
Rob Cozens dba Serendipity Software Company
Manchester, CA USA
Each new generation gives more attention to the man-made world...
and less attention to the world that made man.
-
SparkOut
- Posts: 2852
- Joined: Sun Sep 23, 2007 4:58 pm
Post
by SparkOut » Tue Sep 28, 2021 7:09 pm
On Windows 9.6.5_64 bit version, I get the same broken gif snapshotted, whether output to file or to a newly created image.
-
RCozens
- Posts: 138
- Joined: Thu Aug 05, 2021 6:42 am
- Location: Manchester, CA USA
Post
by RCozens » Tue Sep 28, 2021 7:11 pm
Klaus wrote: ↑Tue Sep 28, 2021 6:53 pm
In the first two lines you try to use the STRING "Gif" as the format, but obviously LC does not like that.
That is the essence of my question Klaus: Why can't LiveCode resolve the "as type" argument at runtime? I have the workaround in the form of a switch, but wonder if there is a specific reason why "as type" can't be resolved at runtime when so many other command arguments can be.
Not a big issue; just an idle wondering.
Rob Cozens dba Serendipity Software Company
Manchester, CA USA
Each new generation gives more attention to the man-made world...
and less attention to the world that made man.