Export snapshot with effects?

Visuals, audio, animation. Blended, not stirred. If LiveCode is part of your rich media production toolbox, this is the forum for you.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
thatkeith
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 346
Joined: Mon Mar 01, 2010 7:13 pm
Location: London, UK
Contact:

Export snapshot with effects?

Post by thatkeith » Wed Mar 14, 2018 12:46 am

I'd like to export the visual state of an image with an ink mode applied. It looked like 'export snapshot' would allow this, but either I can't figure out the script form or it's not working as it should. I hope – like normal – it's my fault and there's a solution waiting to hit me between the eyes!

I've tried this:

Code: Select all

export snapshot from image 1 with effects blendDarken to file specialFolderPath("desktop") & "/snapshot.jpg" as JPEG
and a few close variations but the code never gets the thumbs up from the script editor. If I remove "with effects blendDarken" it's fine. Is that because that's an ink mode not a blend level? If I use the form without specifying any rect I get the traditional crosshairs cursor, and the result shows it as expected. But otherwise it just captures the area as if no custom ink effect was applied.

Any advice?

Keith
Technical Writer, Meta
University Lecturer
Technical Editor, MacUser (1996-2015)
360 VR media specialist

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Export snapshot with effects?

Post by bogs » Wed Mar 14, 2018 3:37 am

You almost have it thatkeith.

What 'with effects' actually seems to mean is that, if you have an image you've applied effects to, like dropShadow, for instance, you can transfer that snapshot with that effect (or multiple applied effects).

Set up a stack with a button and import an image, then make a second empty image. Code for the button -

Code: Select all

on mouseUp
   export snapshot from image "imgOne" with effects to image "imgTwo"
end mouseUp
For the first click of the button, leave the image as you originally imported it. You'll see it winds up in imgTwo unchanged.

Before you click again, set an effect, blendLevel, or both to image "imgOne", then click the button again, you should see the difference, although it may not be what you expect :D
Selection_003.png
Selection_003.png (42.67 KiB) Viewed 11881 times
*Edit - for a slightly more in-depth example, you can look at this lesson.
Image

thatkeith
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 346
Joined: Mon Mar 01, 2010 7:13 pm
Location: London, UK
Contact:

Re: Export snapshot with effects?

Post by thatkeith » Wed Mar 14, 2018 9:14 am

Aha! That's very enlightening - thanks! I got it working to the level in your screengrab, and the example in the page you suggested is also helpful.

It does seem that the export snapshot process is logically inconsistent, in that it doesn't actually capture literally the full visual state of the area but rather a specific subset of the possible visual effects. Specifically, why no ink effect? :-/

What I was trying to do was take a still from the camera feed, use an ink mode to produce a visual blend with the image underneath the captured still (something more interesting than just changing blend/transparency level), and export the result as a captured image. There are quirks still that I have to work out, but it's a bit hit and miss. For example, specifying a rect in numbers rather than specifying an object as the source area fails:

Code: Select all

export snapshot from rect "34,50,674,410" with effects to image 2
I'll keep trying. :)
Technical Writer, Meta
University Lecturer
Technical Editor, MacUser (1996-2015)
360 VR media specialist

thatkeith
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 346
Joined: Mon Mar 01, 2010 7:13 pm
Location: London, UK
Contact:

Re: Export snapshot with effects?

Post by thatkeith » Wed Mar 14, 2018 10:25 am

Here's a boiled down example of this 'working' – i.e. capturing a snapshot with some visual effects intact but not including any non-srcCopy ink appearance:

Code: Select all

cameraControlDo "camera1", "takePicture"
put the result into image "source"
(The "source" image's ink is set to blendOverlay; it looks good at this point.)

Code: Select all

import snapshot from image "source" with effects
This creates a new image object set with the source's image, BUT the captured image shows no sign of the ink appearance. However, if a blend level or an effect such as drop shadow is set, this is captured properly.
Technical Writer, Meta
University Lecturer
Technical Editor, MacUser (1996-2015)
360 VR media specialist

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Export snapshot with effects?

Post by bogs » Wed Mar 14, 2018 2:41 pm

Import and export from Max's wiki (little better explanation of 'effects').
MaxV's wiki wrote: effect - Specifies whether graphic effects (like dropShadow, InnerShadow, innerGlow, outerGlow, colorOverlay) and a blendLevel should be applied to the object before rendering export.
In older versions of Lc, you also have qtEffects, although not sure that would apply here. In any case, I never found the 'ink' blends listed in any discussion I came across. On the other hand, I only started looking since you brought up the topic, so take that with a grain of granite :D

As far as rectangles go (manually entered or programmatically gotten through code), if the rect is in relation to the stack/card, I think using 'effective' is required for less than funny results, even when using a line like

Code: Select all

the rect of image "image"
What happens (understandably) is that Lc interprets that to be the rect of the image, so lets say your image is on the card at [10,10,250,400], but without 'effective', it will probably calculate the 10,10 to be from the screen instead of the card, so you won't be getting the area you think you will.

Glad you got it worked out for the most part :)
Image

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7214
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Export snapshot with effects?

Post by jacque » Wed Mar 14, 2018 4:27 pm

It should work if you export the snapshot using a rectangle specification. You can convert card locs to screen locs using the globalLoc() function.

So basically convert the topleft of the image to screen coordinates, do the same for the bottomRight, concatenate the two sets with a comma, and use that rectangle for the export snapshot command.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

thatkeith
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 346
Joined: Mon Mar 01, 2010 7:13 pm
Location: London, UK
Contact:

Re: Export snapshot with effects?

Post by thatkeith » Wed Mar 14, 2018 10:14 pm

Brilliant, thanks Jacque! Quick & dirty test:

Code: Select all

put globalLoc(the topLeft of image 1) & "," & globalLoc(the bottomRight of image 1) into theArea
export snapshot from rect theArea to image 2
Works exactly as I wanted – an exact imageData replica of the specified area. Happy bunny. :)

k
Technical Writer, Meta
University Lecturer
Technical Editor, MacUser (1996-2015)
360 VR media specialist

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Export snapshot with effects?

Post by bogs » Wed Mar 14, 2018 10:32 pm

She is quite brilliant, isn't she? Now, if she could only tell me where to put that altar I was erecting... :wink:
Image

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7214
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Export snapshot with effects?

Post by jacque » Thu Mar 15, 2018 12:17 am

bogs wrote:
Wed Mar 14, 2018 10:32 pm
Now, if she could only tell me where to put that altar I was erecting... :wink:
You don't really want me to tell you where to put it, do you? ;)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Export snapshot with effects?

Post by bogs » Thu Mar 15, 2018 2:12 am

No, I'm pretty sure they won't mind if I stick it right by the Eiffel Tower. After all, it won't be much larger than that... :twisted:
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9286
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Export snapshot with effects?

Post by richmond62 » Thu Mar 11, 2021 9:33 am

Personally I prefer to us IMPORT first of all to check whether EFFECTS have "taken":

Slight modification of Jacque's lovely code:

Code: Select all

on mouseUp
   put globalLoc(the topLeft of img "UI") & "," & globalLoc(the bottomRight of img "UI") into QUAD
   import snapshot from rect QUAD
   set the name of last image to "newThing"
   move img "newThing" to 750,300
end mouseUp
-
CatAttack.jpg
-

The value of importing the image with its applied effects is that one can either add further effects
or simply trash the thing and go back and "fiddle around" until one gets what one wants.

One can then EXPORT the imgae "newThing" when one is satisfied with the results.

Then I thought I'd try and be clever . . .

But this (which the scriptEditor said was OK) threw a bluey:

Code: Select all

on mouseUp
   import snapshot from the rect of img "UI"
   set the name of last image to "newThing"
   move img "newThing" to 750,300
end mouseUp
At which point I began to wonder what the point of RECT was.

Code: Select all

on mouseUp
   put the rect of img "UI" into QUAD
   import snapshot from rect QUAD
   set the name of last image to "newThing"
   move img "newThing" to 750,300
end mouseUp
I ended up looking like a "right prawn":
-
SShot 2021-03-11 at 10.24.33.png
-
Attachments
Effects.livecode.zip
Here's the stack
(31.31 KiB) Downloaded 225 times

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Export snapshot with effects?

Post by Klaus » Thu Mar 11, 2021 12:34 pm

If you just provide a "naked" rect, LC interprets this as GLOBAL coordinates!
Means 0,0 is the topleft corner of your monitor.

If you specify the rect -> of btn(img/etc. of this card/of this stack
then LC uses the topleft of the current stack as 0,0.

But why on earth do you always MOVE things, which is visible, instead of just setting their loc? 8)

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9286
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Export snapshot with effects?

Post by richmond62 » Thu Mar 11, 2021 2:11 pm

But why on earth do you always MOVE things, which is visible, instead of just setting their loc?
'Cos these are only Quick-n-Dirty stacks.

Today's one I knocked up between the sections of a spatty FB discussion
I was having with the mother of one of my pupils who did not want to accept
that her child is a lazy toad. 8)

Post Reply

Return to “Multimedia”