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: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

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

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
Senior Lecturer, LCC (University of the Arts London)
Technical Editor, MacUser (1996-2015)
President, IVRPA.org

bogs
Posts: 2306
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 964 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: 231
Joined: Mon Mar 01, 2010 7:13 pm
Location: London, UK

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. :)
Senior Lecturer, LCC (University of the Arts London)
Technical Editor, MacUser (1996-2015)
President, IVRPA.org

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

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.
Senior Lecturer, LCC (University of the Arts London)
Technical Editor, MacUser (1996-2015)
President, IVRPA.org

bogs
Posts: 2306
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: 4671
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: 231
Joined: Mon Mar 01, 2010 7:13 pm
Location: London, UK

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
Senior Lecturer, LCC (University of the Arts London)
Technical Editor, MacUser (1996-2015)
President, IVRPA.org

bogs
Posts: 2306
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: 4671
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: 2306
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

Post Reply

Return to “Rich Media”