<languageVersion : 1.0;> kernel NewFilter < namespace : "Your Namespace" ; vendor : "Your Vendor" ; version : 1; description : "your description" ; > { input image4 src; input image4 src2; output pixel4 dst; const pixel4 white = float4(1.0, 1.0, 1.0, 1.0); const pixel4 black = float4(0.0, 0.0, 0.0, 0.0); const float min = 0.05; void evaluatePixel() { pixel4 a1 = sampleNearest(src, outCoord()); pixel4 a2 = sampleNearest(src2, outCoord()); pixel4 ss = a1 - a2; dst = (ss.r>min && ss.g>min && ss.b>min) ? white : black; } } * This source code was highlighted with Source Code Highlighter .
<languageVersion : 1.0;> kernel NewFilter < namespace : "Your Namespace" ; vendor : "Your Vendor" ; version : 1; description : "your description" ; > { input image4 src; input image4 src2; output pixel4 dst; const pixel4 white = float4(1.0, 1.0, 1.0, 1.0); const pixel4 black = float4(0.0, 0.0, 0.0, 0.0); const float min = 0.05; void evaluatePixel() { pixel4 a1 = sampleNearest(src, outCoord()); pixel4 a2 = sampleNearest(src2, outCoord()); pixel4 ss = a1 - a2; dst = (ss.r>min && ss.g>min && ss.b>min) ? white : black; } } * This source code was highlighted with Source Code Highlighter .
<languageVersion : 1.0;> kernel NewFilter < namespace : "Your Namespace" ; vendor : "Your Vendor" ; version : 1; description : "your description" ; > { input image4 src; input image4 src2; output pixel4 dst; const pixel4 white = float4(1.0, 1.0, 1.0, 1.0); const pixel4 black = float4(0.0, 0.0, 0.0, 0.0); const float min = 0.05; void evaluatePixel() { pixel4 a1 = sampleNearest(src, outCoord()); pixel4 a2 = sampleNearest(src2, outCoord()); pixel4 ss = a1 - a2; dst = (ss.r>min && ss.g>min && ss.b>min) ? white : black; } } * This source code was highlighted with Source Code Highlighter .
<languageVersion : 1.0;> kernel NewFilter < namespace : "Your Namespace" ; vendor : "Your Vendor" ; version : 1; description : "your description" ; > { input image4 src; input image4 src2; output pixel4 dst; const pixel4 white = float4(1.0, 1.0, 1.0, 1.0); const pixel4 black = float4(0.0, 0.0, 0.0, 0.0); const float min = 0.05; void evaluatePixel() { pixel4 a1 = sampleNearest(src, outCoord()); pixel4 a2 = sampleNearest(src2, outCoord()); pixel4 ss = a1 - a2; dst = (ss.r>min && ss.g>min && ss.b>min) ? white : black; } } * This source code was highlighted with Source Code Highlighter .
<languageVersion : 1.0;> kernel NewFilter < namespace : "Your Namespace" ; vendor : "Your Vendor" ; version : 1; description : "your description" ; > { input image4 src; input image4 src2; output pixel4 dst; const pixel4 white = float4(1.0, 1.0, 1.0, 1.0); const pixel4 black = float4(0.0, 0.0, 0.0, 0.0); const float min = 0.05; void evaluatePixel() { pixel4 a1 = sampleNearest(src, outCoord()); pixel4 a2 = sampleNearest(src2, outCoord()); pixel4 ss = a1 - a2; dst = (ss.r>min && ss.g>min && ss.b>min) ? white : black; } } * This source code was highlighted with Source Code Highlighter .
<languageVersion : 1.0;> kernel NewFilter < namespace : "Your Namespace" ; vendor : "Your Vendor" ; version : 1; description : "your description" ; > { input image4 src; input image4 src2; output pixel4 dst; const pixel4 white = float4(1.0, 1.0, 1.0, 1.0); const pixel4 black = float4(0.0, 0.0, 0.0, 0.0); const float min = 0.05; void evaluatePixel() { pixel4 a1 = sampleNearest(src, outCoord()); pixel4 a2 = sampleNearest(src2, outCoord()); pixel4 ss = a1 - a2; dst = (ss.r>min && ss.g>min && ss.b>min) ? white : black; } } * This source code was highlighted with Source Code Highlighter .
<languageVersion : 1.0;> kernel NewFilter < namespace : "Your Namespace" ; vendor : "Your Vendor" ; version : 1; description : "your description" ; > { input image4 src; input image4 src2; output pixel4 dst; const pixel4 white = float4(1.0, 1.0, 1.0, 1.0); const pixel4 black = float4(0.0, 0.0, 0.0, 0.0); const float min = 0.05; void evaluatePixel() { pixel4 a1 = sampleNearest(src, outCoord()); pixel4 a2 = sampleNearest(src2, outCoord()); pixel4 ss = a1 - a2; dst = (ss.r>min && ss.g>min && ss.b>min) ? white : black; } } * This source code was highlighted with Source Code Highlighter .
<languageVersion : 1.0;> kernel NewFilter < namespace : "Your Namespace" ; vendor : "Your Vendor" ; version : 1; description : "your description" ; > { input image4 src; input image4 src2; output pixel4 dst; const pixel4 white = float4(1.0, 1.0, 1.0, 1.0); const pixel4 black = float4(0.0, 0.0, 0.0, 0.0); const float min = 0.05; void evaluatePixel() { pixel4 a1 = sampleNearest(src, outCoord()); pixel4 a2 = sampleNearest(src2, outCoord()); pixel4 ss = a1 - a2; dst = (ss.r>min && ss.g>min && ss.b>min) ? white : black; } } * This source code was highlighted with Source Code Highlighter .
<languageVersion : 1.0;> kernel NewFilter < namespace : "Your Namespace" ; vendor : "Your Vendor" ; version : 1; description : "your description" ; > { input image4 src; input image4 src2; output pixel4 dst; const pixel4 white = float4(1.0, 1.0, 1.0, 1.0); const pixel4 black = float4(0.0, 0.0, 0.0, 0.0); const float min = 0.05; void evaluatePixel() { pixel4 a1 = sampleNearest(src, outCoord()); pixel4 a2 = sampleNearest(src2, outCoord()); pixel4 ss = a1 - a2; dst = (ss.r>min && ss.g>min && ss.b>min) ? white : black; } } * This source code was highlighted with Source Code Highlighter .
<languageVersion : 1.0;> kernel NewFilter < namespace : "Your Namespace" ; vendor : "Your Vendor" ; version : 1; description : "your description" ; > { input image4 src; input image4 src2; output pixel4 dst; const pixel4 white = float4(1.0, 1.0, 1.0, 1.0); const pixel4 black = float4(0.0, 0.0, 0.0, 0.0); const float min = 0.05; void evaluatePixel() { pixel4 a1 = sampleNearest(src, outCoord()); pixel4 a2 = sampleNearest(src2, outCoord()); pixel4 ss = a1 - a2; dst = (ss.r>min && ss.g>min && ss.b>min) ? white : black; } } * This source code was highlighted with Source Code Highlighter .
<languageVersion : 1.0;> kernel NewFilter < namespace : "Your Namespace" ; vendor : "Your Vendor" ; version : 1; description : "your description" ; > { input image4 src; input image4 src2; output pixel4 dst; const pixel4 white = float4(1.0, 1.0, 1.0, 1.0); const pixel4 black = float4(0.0, 0.0, 0.0, 0.0); const float min = 0.05; void evaluatePixel() { pixel4 a1 = sampleNearest(src, outCoord()); pixel4 a2 = sampleNearest(src2, outCoord()); pixel4 ss = a1 - a2; dst = (ss.r>min && ss.g>min && ss.b>min) ? white : black; } } * This source code was highlighted with Source Code Highlighter .
<languageVersion : 1.0;> kernel NewFilter < namespace : "Your Namespace" ; vendor : "Your Vendor" ; version : 1; description : "your description" ; > { input image4 src; input image4 src2; output pixel4 dst; const pixel4 white = float4(1.0, 1.0, 1.0, 1.0); const pixel4 black = float4(0.0, 0.0, 0.0, 0.0); const float min = 0.05; void evaluatePixel() { pixel4 a1 = sampleNearest(src, outCoord()); pixel4 a2 = sampleNearest(src2, outCoord()); pixel4 ss = a1 - a2; dst = (ss.r>min && ss.g>min && ss.b>min) ? white : black; } } * This source code was highlighted with Source Code Highlighter .
<languageVersion : 1.0;> kernel NewFilter < namespace : "Your Namespace" ; vendor : "Your Vendor" ; version : 1; description : "your description" ; > { input image4 src; input image4 src2; output pixel4 dst; const pixel4 white = float4(1.0, 1.0, 1.0, 1.0); const pixel4 black = float4(0.0, 0.0, 0.0, 0.0); const float min = 0.05; void evaluatePixel() { pixel4 a1 = sampleNearest(src, outCoord()); pixel4 a2 = sampleNearest(src2, outCoord()); pixel4 ss = a1 - a2; dst = (ss.r>min && ss.g>min && ss.b>min) ? white : black; } } * This source code was highlighted with Source Code Highlighter .
<languageVersion : 1.0;> kernel NewFilter < namespace : "Your Namespace" ; vendor : "Your Vendor" ; version : 1; description : "your description" ; > { input image4 src; input image4 src2; output pixel4 dst; const pixel4 white = float4(1.0, 1.0, 1.0, 1.0); const pixel4 black = float4(0.0, 0.0, 0.0, 0.0); const float min = 0.05; void evaluatePixel() { pixel4 a1 = sampleNearest(src, outCoord()); pixel4 a2 = sampleNearest(src2, outCoord()); pixel4 ss = a1 - a2; dst = (ss.r>min && ss.g>min && ss.b>min) ? white : black; } } * This source code was highlighted with Source Code Highlighter .
<languageVersion : 1.0;> kernel NewFilter < namespace : "Your Namespace" ; vendor : "Your Vendor" ; version : 1; description : "your description" ; > { input image4 src; input image4 src2; output pixel4 dst; const pixel4 white = float4(1.0, 1.0, 1.0, 1.0); const pixel4 black = float4(0.0, 0.0, 0.0, 0.0); const float min = 0.05; void evaluatePixel() { pixel4 a1 = sampleNearest(src, outCoord()); pixel4 a2 = sampleNearest(src2, outCoord()); pixel4 ss = a1 - a2; dst = (ss.r>min && ss.g>min && ss.b>min) ? white : black; } } * This source code was highlighted with Source Code Highlighter .
<languageVersion : 1.0;> kernel NewFilter < namespace : "Your Namespace" ; vendor : "Your Vendor" ; version : 1; description : "your description" ; > { input image4 src; input image4 src2; output pixel4 dst; const pixel4 white = float4(1.0, 1.0, 1.0, 1.0); const pixel4 black = float4(0.0, 0.0, 0.0, 0.0); const float min = 0.05; void evaluatePixel() { pixel4 a1 = sampleNearest(src, outCoord()); pixel4 a2 = sampleNearest(src2, outCoord()); pixel4 ss = a1 - a2; dst = (ss.r>min && ss.g>min && ss.b>min) ? white : black; } } * This source code was highlighted with Source Code Highlighter .
<languageVersion : 1.0;> kernel NewFilter < namespace : "Your Namespace" ; vendor : "Your Vendor" ; version : 1; description : "your description" ; > { input image4 src; input image4 src2; output pixel4 dst; const pixel4 white = float4(1.0, 1.0, 1.0, 1.0); const pixel4 black = float4(0.0, 0.0, 0.0, 0.0); const float min = 0.05; void evaluatePixel() { pixel4 a1 = sampleNearest(src, outCoord()); pixel4 a2 = sampleNearest(src2, outCoord()); pixel4 ss = a1 - a2; dst = (ss.r>min && ss.g>min && ss.b>min) ? white : black; } } * This source code was highlighted with Source Code Highlighter .
<languageVersion : 1.0;> kernel NewFilter < namespace : "Your Namespace" ; vendor : "Your Vendor" ; version : 1; description : "your description" ; > { input image4 src; input image4 src2; output pixel4 dst; const pixel4 white = float4(1.0, 1.0, 1.0, 1.0); const pixel4 black = float4(0.0, 0.0, 0.0, 0.0); const float min = 0.05; void evaluatePixel() { pixel4 a1 = sampleNearest(src, outCoord()); pixel4 a2 = sampleNearest(src2, outCoord()); pixel4 ss = a1 - a2; dst = (ss.r>min && ss.g>min && ss.b>min) ? white : black; } } * This source code was highlighted with Source Code Highlighter .
<languageVersion : 1.0;> kernel NewFilter < namespace : "Your Namespace" ; vendor : "Your Vendor" ; version : 1; description : "your description" ; > { input image4 src; input image4 src2; output pixel4 dst; const pixel4 white = float4(1.0, 1.0, 1.0, 1.0); const pixel4 black = float4(0.0, 0.0, 0.0, 0.0); const float min = 0.05; void evaluatePixel() { pixel4 a1 = sampleNearest(src, outCoord()); pixel4 a2 = sampleNearest(src2, outCoord()); pixel4 ss = a1 - a2; dst = (ss.r>min && ss.g>min && ss.b>min) ? white : black; } } * This source code was highlighted with Source Code Highlighter .
<languageVersion : 1.0;> kernel NewFilter < namespace : "Your Namespace" ; vendor : "Your Vendor" ; version : 1; description : "your description" ; > { input image4 src; input image4 src2; output pixel4 dst; const pixel4 white = float4(1.0, 1.0, 1.0, 1.0); const pixel4 black = float4(0.0, 0.0, 0.0, 0.0); const float min = 0.05; void evaluatePixel() { pixel4 a1 = sampleNearest(src, outCoord()); pixel4 a2 = sampleNearest(src2, outCoord()); pixel4 ss = a1 - a2; dst = (ss.r>min && ss.g>min && ss.b>min) ? white : black; } } * This source code was highlighted with Source Code Highlighter .
<languageVersion : 1.0;> kernel NewFilter < namespace : "Your Namespace" ; vendor : "Your Vendor" ; version : 1; description : "your description" ; > { input image4 src; input image4 src2; output pixel4 dst; const pixel4 white = float4(1.0, 1.0, 1.0, 1.0); const pixel4 black = float4(0.0, 0.0, 0.0, 0.0); const float min = 0.05; void evaluatePixel() { pixel4 a1 = sampleNearest(src, outCoord()); pixel4 a2 = sampleNearest(src2, outCoord()); pixel4 ss = a1 - a2; dst = (ss.r>min && ss.g>min && ss.b>min) ? white : black; } } * This source code was highlighted with Source Code Highlighter .
<languageVersion : 1.0;> kernel NewFilter < namespace : "Your Namespace" ; vendor : "Your Vendor" ; version : 1; description : "your description" ; > { input image4 src; input image4 src2; output pixel4 dst; const pixel4 white = float4(1.0, 1.0, 1.0, 1.0); const pixel4 black = float4(0.0, 0.0, 0.0, 0.0); const float min = 0.05; void evaluatePixel() { pixel4 a1 = sampleNearest(src, outCoord()); pixel4 a2 = sampleNearest(src2, outCoord()); pixel4 ss = a1 - a2; dst = (ss.r>min && ss.g>min && ss.b>min) ? white : black; } } * This source code was highlighted with Source Code Highlighter .
<languageVersion : 1.0;> kernel NewFilter < namespace : "Your Namespace" ; vendor : "Your Vendor" ; version : 1; description : "your description" ; > { input image4 src; input image4 src2; output pixel4 dst; const pixel4 white = float4(1.0, 1.0, 1.0, 1.0); const pixel4 black = float4(0.0, 0.0, 0.0, 0.0); const float min = 0.05; void evaluatePixel() { pixel4 a1 = sampleNearest(src, outCoord()); pixel4 a2 = sampleNearest(src2, outCoord()); pixel4 ss = a1 - a2; dst = (ss.r>min && ss.g>min && ss.b>min) ? white : black; } } * This source code was highlighted with Source Code Highlighter .
<languageVersion : 1.0;> kernel NewFilter < namespace : "Your Namespace" ; vendor : "Your Vendor" ; version : 1; description : "your description" ; > { input image4 src; input image4 src2; output pixel4 dst; const pixel4 white = float4(1.0, 1.0, 1.0, 1.0); const pixel4 black = float4(0.0, 0.0, 0.0, 0.0); const float min = 0.05; void evaluatePixel() { pixel4 a1 = sampleNearest(src, outCoord()); pixel4 a2 = sampleNearest(src2, outCoord()); pixel4 ss = a1 - a2; dst = (ss.r>min && ss.g>min && ss.b>min) ? white : black; } } * This source code was highlighted with Source Code Highlighter .
<languageVersion : 1.0;> kernel NewFilter < namespace : "Your Namespace" ; vendor : "Your Vendor" ; version : 1; description : "your description" ; > { input image4 src; input image4 src2; output pixel4 dst; const pixel4 white = float4(1.0, 1.0, 1.0, 1.0); const pixel4 black = float4(0.0, 0.0, 0.0, 0.0); const float min = 0.05; void evaluatePixel() { pixel4 a1 = sampleNearest(src, outCoord()); pixel4 a2 = sampleNearest(src2, outCoord()); pixel4 ss = a1 - a2; dst = (ss.r>min && ss.g>min && ss.b>min) ? white : black; } } * This source code was highlighted with Source Code Highlighter .
* This source code was highlighted with Source Code Highlighter .
- package {
- import flash.display.Bitmap;
- import flash.display.BitmapData;
- import flash.display.Shader;
- import flash.display.ShaderJob;
- import flash.display.Sprite;
- import flash.events.Event;
- import flash.filters.BlurFilter;
- import flash.filters.ColorMatrixFilter;
- import flash.geom.Point;
- import flash.media.Video;
- import flash.net.NetConnection;
- import flash.net.NetStream;
- import flash.utils.ByteArray;
- [SWF (width = 376, height = 160, backgroundColor = 0x0)]
- public class SubstractTv extends Sprite {
- [Embed (source = "../assets/kutu.pbj" , mimeType = "application / octet-stream" )]
- private var pbj: Class;
- private var wid: uint = stage.stageWidth;
- private var hei: uint = stage.stageHeight;
- private var video: Video;
- private var nc: NetConnection;
- private var ns: NetStream;
- private var bmp1: BitmapData;
- private var bmp2: BitmapData;
- private var bmp3: BitmapData;
- private var out : BitmapData;
- private var bmp: Bitmap;
- private var shader: Shader;
- private var shaderJob: ShaderJob;
- private var blur: BlurFilter;
- private var cmf: ColorMatrixFilter;
- public function SubstractTv () {
- nc = new NetConnection ();
- nc.connect ( null );
- ns = new NetStream (nc);
- ns.client = new Object ();
- ns.play ( "video.f4v" );
- video = new Video (wid, hei);
- video.attachNetStream (ns);
- bmp1 = new BitmapData (wid, hei, true );
- bmp2 = bmp1.clone ();
- bmp3 = bmp1.clone ();
- out = bmp1.clone ();
- bmp = new Bitmap ( out , "auto" , true );
- addChild (bmp);
- shader = new Shader ( new pbj () as ByteArray);
- shader.data.src.input = bmp1;
- shader.data.src2.input = bmp2;
- createShaderJob ();
- addEventListener (Event.ENTER_FRAME, onEnterFrame);
- blur = new BlurFilter (3, 3, 3);
- cmf = new ColorMatrixFilter ([1, 0, 0, 0, 0,
- 0, 1, 0, 0, 0,
- 0, 0, 1, 0, 0,
- 0, 0, 0, 1, -10]);
- }
- private function onEnterFrame (e: Event): void {
- if (shaderJob.progress! = 1) return ;
- bmp2.draw (bmp1);
- try {
- bmp1.draw (video);
- } catch (e: Error) {}
- createShaderJob ();
- out .applyFilter ( out , out .rect, new Point (), blur);
- out .applyFilter ( out , out .rect, new Point (), cmf);
- out .draw (bmp3);
- }
- private function createShaderJob (): void {
- shaderJob = new ShaderJob (shader, bmp3, wid, hei);
- shaderJob.start ();
- }
- }
- }
Source: https://habr.com/ru/post/46647/
All Articles