Fast method for shaped screenshot?

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

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2234
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Fast method for shaped screenshot?

Post by [-hh] » Sat Feb 06, 2016 1:55 am

Hi multimedia specialists,

meanwhile I found a solution for non-rectangular window-shaped screenshots.

Resizing 'on-the-fly' is no problem with non-rectangular window shapes, it's even fast enough on a Raspi.
What's making some speed-problems is to do the "shaped" screenshot.

See attachment and the screenshots here (Shaped RaspiStack #2)
http://forums.livecode.com/viewtopic.ph ... 40#p137640
[Runs on Mac/Win/Linux/RaspiB/Raspi2 (I didn't test mobiles for now).]

It needs at about 800 millisecs on a medium fast machine (2.5 GHz)
for that [1800 ms on Raspi 2] and these 5 steps (starting from step0):

0. Start status: The frame is placed (image I below).
1. Make a rectangular screenshot A.
2. Set windowshape to 0, frame to opaque.
3. Make a screenshot B of the opaque frame.
4. Save the shot A with mask from B as "framed shot" (image II below).
5. Set windowshape back to the original frame (image II below).
[Attached images are scaled to width 390 to fit the forum needs.]

A simple (unframed) rectangular screenshot needs in total < 200 milliseconds
only on a medium fast machine [< 500 ms on Raspi 2] and one single step.

Is there a simpler/faster way to do such a framed screenshot?

My solution looks rather complicated but I couldn't find another way.
In the stack cited above are some actions that could also be "surrounded" by
lock screen; lock messages ... unlock screen; unlock messages.
These works on some (fast) machines, on others not.

So, with first priority, I'm looking for a better solution that works (as mine) on Mac/Win/Linux+Raspi.

Hermann

[Edit. Added attachments]
Attachments
shaped0.png
[I] Steps 0 and 5 above
shaped4.png
[II] Step 4 above (= what we want, frame colour is choosable)
shiftLock happens

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3336
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Fast method for shaped screenshot?

Post by bn » Tue Feb 09, 2016 8:19 am

Here is a little proof of concept stack that uses WindowShape and makes snapshots from the area behind the shape framed by the shape.

You can drag the stack around by click-dragging in the blue oval border
Command-click generates a screenshot of the area visible inside the the windowShape. (if there is not a folder "BNSnaps" then one will be created next to the stack and the snapshots names consist of milliseconds.png)
Alt-clicking on shape will exit windowShape mode and reveals two buttons:
"SetWindowShape" will reenter into windowShape mode
"toggleOvalTriangle" will toggle between a oval and a triangle used for the windowShape and snapshots.

The main script is in graphic "ione"
the stack uses one graphic "ione" that is used via snapshot to generate the image for the windowShape which is image "ione"
Taking a snapshot from the area behind the stack this snapshot goes into image "temp"
Applying the shape to the rectangular snapshot from behind the stack is done by taking a snapshot from group "ione".
here grapic "ione" is in front of image "temp" and graphic "ione" has its inkmode set to "blendDstIn". This way only the part of image "temp" that fits into the inside of graphic "ione" + the border of graphic "ione" will be exported.


If this sounds complicated then because it is a bit involved. But the stack is reduce to essentially the minumum of what you need to do this.

Why this stack? Hermann asked for a little speed improvement and here the steps to arrive at the snapshot are reduced resulting in an improved performance.

If you want to resize the stack/shape then stop WindowShape mode (remember: alt-click on frame), resize the stack in the usual way and reapply the windowShape.

Kind regards
Bernd
Attachments
windowShapeSnap_bn2.livecode.zip
(120.91 KiB) Downloaded 104 times

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2234
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Fast method for shaped screenshot?

Post by [-hh] » Tue Feb 09, 2016 8:56 pm

Hi Bernd,

very nice trick to use ink effects here. Will try to use this effectively.

Thanks, especially for the clear description.

Hermann
shiftLock happens

Post Reply

Return to “Rich Media”