diff --git a/WpfExtended.Test/MainWindow.xaml.cs b/WpfExtended.Test/MainWindow.xaml.cs index 2b26c6c..76b0bf4 100644 --- a/WpfExtended.Test/MainWindow.xaml.cs +++ b/WpfExtended.Test/MainWindow.xaml.cs @@ -39,8 +39,8 @@ namespace WpfExtended.Test var effect = Activator.CreateInstance(effectType).As(); var image = new CaptionedImage() { - Width = 300, - Height = 300, + Width = 800, + Height = 800, ImageSource = this.ImageSource, Caption = effect.GetType().Name, ImageEffect = effect, diff --git a/WpfExtended/Effects/BandedSwirl/BandedSwirl.ps b/WpfExtended/Effects/BandedSwirl/BandedSwirl.ps index 718c413..733846d 100644 Binary files a/WpfExtended/Effects/BandedSwirl/BandedSwirl.ps and b/WpfExtended/Effects/BandedSwirl/BandedSwirl.ps differ diff --git a/WpfExtended/Effects/Bloom/Bloom.ps b/WpfExtended/Effects/Bloom/Bloom.ps index c8846e5..c3563d8 100644 Binary files a/WpfExtended/Effects/Bloom/Bloom.ps and b/WpfExtended/Effects/Bloom/Bloom.ps differ diff --git a/WpfExtended/Effects/BrightExtract/BrightExtract.ps b/WpfExtended/Effects/BrightExtract/BrightExtract.ps index 41a06db..1c2a0a5 100644 Binary files a/WpfExtended/Effects/BrightExtract/BrightExtract.ps and b/WpfExtended/Effects/BrightExtract/BrightExtract.ps differ diff --git a/WpfExtended/Effects/ColorKeyAlpha/ColorKeyAlpha.ps b/WpfExtended/Effects/ColorKeyAlpha/ColorKeyAlpha.ps index dc92707..78ad893 100644 Binary files a/WpfExtended/Effects/ColorKeyAlpha/ColorKeyAlpha.ps and b/WpfExtended/Effects/ColorKeyAlpha/ColorKeyAlpha.ps differ diff --git a/WpfExtended/Effects/ColorTone/ColorTone.ps b/WpfExtended/Effects/ColorTone/ColorTone.ps index 0113ee2..60a0a0b 100644 Binary files a/WpfExtended/Effects/ColorTone/ColorTone.ps and b/WpfExtended/Effects/ColorTone/ColorTone.ps differ diff --git a/WpfExtended/Effects/ContrastAdjust/ContrastAdjust.ps b/WpfExtended/Effects/ContrastAdjust/ContrastAdjust.ps index 7f8ffc4..ce56650 100644 Binary files a/WpfExtended/Effects/ContrastAdjust/ContrastAdjust.ps and b/WpfExtended/Effects/ContrastAdjust/ContrastAdjust.ps differ diff --git a/WpfExtended/Effects/DirectionalBlur/DirectionalBlur.ps b/WpfExtended/Effects/DirectionalBlur/DirectionalBlur.ps index f135258..117caa0 100644 Binary files a/WpfExtended/Effects/DirectionalBlur/DirectionalBlur.ps and b/WpfExtended/Effects/DirectionalBlur/DirectionalBlur.ps differ diff --git a/WpfExtended/Effects/Embossed/Embossed.ps b/WpfExtended/Effects/Embossed/Embossed.ps index 115486b..1f8c9d3 100644 Binary files a/WpfExtended/Effects/Embossed/Embossed.ps and b/WpfExtended/Effects/Embossed/Embossed.ps differ diff --git a/WpfExtended/Effects/Gloom/Gloom.ps b/WpfExtended/Effects/Gloom/Gloom.ps index 06bc3df..8fdaacc 100644 Binary files a/WpfExtended/Effects/Gloom/Gloom.ps and b/WpfExtended/Effects/Gloom/Gloom.ps differ diff --git a/WpfExtended/Effects/GrowablePoissonDisk/GrowablePoissonDisk.ps b/WpfExtended/Effects/GrowablePoissonDisk/GrowablePoissonDisk.ps index 117f1d1..5de8305 100644 Binary files a/WpfExtended/Effects/GrowablePoissonDisk/GrowablePoissonDisk.ps and b/WpfExtended/Effects/GrowablePoissonDisk/GrowablePoissonDisk.ps differ diff --git a/WpfExtended/Effects/InvertColor/InvertColor.ps b/WpfExtended/Effects/InvertColor/InvertColor.ps index 8b02f7a..875f4af 100644 Binary files a/WpfExtended/Effects/InvertColor/InvertColor.ps and b/WpfExtended/Effects/InvertColor/InvertColor.ps differ diff --git a/WpfExtended/Effects/Kuwahara/Kuwahara.cs b/WpfExtended/Effects/Kuwahara/Kuwahara.cs new file mode 100644 index 0000000..0174a86 --- /dev/null +++ b/WpfExtended/Effects/Kuwahara/Kuwahara.cs @@ -0,0 +1,61 @@ +// (c) Copyright Microsoft Corporation. +// This source is subject to the Microsoft Permissive License. +// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx. +// All other rights reserved. + +using System.Windows.Media.Effects; + +namespace System.Windows.Media.Extensions.Effects +{ +#if SILVERLIGHT + using UIPropertyMetadata = System.Windows.PropertyMetadata ; +#endif + public class Kuwahara : ShaderEffect + { + public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(Kuwahara), 0); + public static readonly DependencyProperty RadiusProperty = DependencyProperty.Register("Radius", typeof(double), typeof(Kuwahara), new UIPropertyMetadata(1.0, PixelShaderConstantCallback(0))); + public static readonly DependencyProperty TexelWidthProperty = DependencyProperty.Register("TexelWidth", typeof(double), typeof(Kuwahara), new UIPropertyMetadata(100.0, PixelShaderConstantCallback(1))); + public static readonly DependencyProperty TexelHeightProperty = DependencyProperty.Register("TexelHeight", typeof(double), typeof(Kuwahara), new UIPropertyMetadata(100.0, PixelShaderConstantCallback(2))); + + private readonly static PixelShader pixelShader = new(); + + static Kuwahara() + { + pixelShader = PixelShaderUtility.LoadPixelShader(); + } + + public Kuwahara() + { + this.PixelShader = pixelShader; + + // Update each DependencyProperty that's registered with a shader register. This + // is needed to ensure the shader gets sent the proper default value. + UpdateShaderValue(InputProperty); + UpdateShaderValue(RadiusProperty); + UpdateShaderValue(TexelWidthProperty); + UpdateShaderValue(TexelHeightProperty); + } + + [System.ComponentModel.BrowsableAttribute(false)] + public Brush Input + { + get { return (Brush)GetValue(InputProperty); } + set { SetValue(InputProperty, value); } + } + public double Radius + { + get { return (double)GetValue(RadiusProperty); } + set { SetValue(RadiusProperty, value); } + } + public double TexelWidth + { + get { return (double)GetValue(TexelWidthProperty); } + set { SetValue(TexelWidthProperty, value); } + } + public double TexelHeight + { + get { return (double)GetValue(TexelHeightProperty); } + set { SetValue(TexelHeightProperty, value); } + } + } +} diff --git a/WpfExtended/Effects/Kuwahara/Kuwahara.fx b/WpfExtended/Effects/Kuwahara/Kuwahara.fx new file mode 100644 index 0000000..953303d --- /dev/null +++ b/WpfExtended/Effects/Kuwahara/Kuwahara.fx @@ -0,0 +1,100 @@ +// Sampler Registers // + +sampler2D implicitInputSampler : register(S0); + +// Constants Registers // + +float radius : register(C0); +float width : register(C1); +float height : register(C2); + +half getGray(half4 c) +{ + return(dot(c.rgb, ((0.33333).xxx))); +} + +#define GrabPix(n,a) half3 n = tex2D(implicitInputSampler,(a)).xyz; + +float4 main(float2 uv : TEXCOORD) : COLOR +{ + half2 ox = half2(radius / width, 0.0); + half2 oy = half2(0.0, radius / height); + half2 ox2 = 2 * ox; + half2 oy2 = 2 * oy; + half2 PP = uv - oy2; + GrabPix(c00, PP - ox2) + GrabPix(c01, PP - ox) + GrabPix(c02, PP) + GrabPix(c03, PP + ox) + GrabPix(c04, PP + ox2) + PP = uv - oy; + GrabPix(c10, PP - ox2) + GrabPix(c11, PP - ox) + GrabPix(c12, PP) + GrabPix(c13, PP + ox) + GrabPix(c14, PP + ox2) + PP = uv; + GrabPix(c20, PP - ox2) + GrabPix(c21, PP - ox) + GrabPix(c22, PP) + GrabPix(c23, PP + ox) + GrabPix(c24, PP + ox2) + half3 m00 = (c00 + c01 + c02 + c10 + c11 + c12 + c20 + c21 + c22) / 9; + half3 d = (c00 - m00); half v00 = dot(d, d); + d = (c01 - m00); v00 += dot(d, d); + d = (c02 - m00); v00 += dot(d, d); + d = (c10 - m00); v00 += dot(d, d); + d = (c11 - m00); v00 += dot(d, d); + d = (c12 - m00); v00 += dot(d, d); + d = (c20 - m00); v00 += dot(d, d); + d = (c21 - m00); v00 += dot(d, d); + d = (c12 - m00); v00 += dot(d, d); + half3 m01 = (c02 + c03 + c04 + c12 + c13 + c14 + c22 + c23 + c24) / 9; + d = (c02 - m01); half v01 = dot(d, d); + d = (c03 - m01); v01 += dot(d, d); + d = (c04 - m01); v01 += dot(d, d); + d = (c12 - m01); v01 += dot(d, d); + d = (c13 - m01); v01 += dot(d, d); + d = (c14 - m01); v01 += dot(d, d); + d = (c22 - m01); v01 += dot(d, d); + d = (c23 - m01); v01 += dot(d, d); + d = (c14 - m01); v01 += dot(d, d); + PP = uv + oy; + GrabPix(c30, PP - ox2) + GrabPix(c31, PP - ox) + GrabPix(c32, PP) + GrabPix(c33, PP + ox) + GrabPix(c34, PP + ox2) + PP = uv + oy; + GrabPix(c40, PP - ox2) + GrabPix(c41, PP - ox) + GrabPix(c42, PP) + GrabPix(c43, PP + ox) + GrabPix(c44, PP + ox2) + half3 m10 = (c20 + c21 + c22 + c30 + c31 + c32 + c40 + c41 + c42) / 9; + d = (c20 - m10); half v10 = dot(d, d); + d = (c21 - m10); v10 += dot(d, d); + d = (c22 - m10); v10 += dot(d, d); + d = (c30 - m10); v10 += dot(d, d); + d = (c31 - m10); v10 += dot(d, d); + d = (c32 - m10); v10 += dot(d, d); + d = (c40 - m10); v10 += dot(d, d); + d = (c41 - m10); v10 += dot(d, d); + d = (c42 - m10); v10 += dot(d, d); + half3 m11 = (c22 + c23 + c24 + c32 + c33 + c34 + c42 + c43 + c44) / 9; + d = (c22 - m11); half v11 = dot(d, d); + d = (c23 - m11); v11 += dot(d, d); + d = (c24 - m11); v11 += dot(d, d); + d = (c32 - m11); v11 += dot(d, d); + d = (c33 - m11); v11 += dot(d, d); + d = (c34 - m11); v11 += dot(d, d); + d = (c42 - m11); v11 += dot(d, d); + d = (c43 - m11); v11 += dot(d, d); + d = (c44 - m11); v11 += dot(d, d); + half3 result = m00; + half rv = v00; + if (v01 < rv) { result = m01; rv = v01; } + if (v10 < rv) { result = m10; rv = v10; } + if (v11 < rv) { result = m11; } + return half4(result, 1); +} \ No newline at end of file diff --git a/WpfExtended/Effects/Kuwahara/Kuwahara.ps b/WpfExtended/Effects/Kuwahara/Kuwahara.ps new file mode 100644 index 0000000..1b55de1 Binary files /dev/null and b/WpfExtended/Effects/Kuwahara/Kuwahara.ps differ diff --git a/WpfExtended/Effects/LightStreak/LightStreak.ps b/WpfExtended/Effects/LightStreak/LightStreak.ps index 2da9620..77025bd 100644 Binary files a/WpfExtended/Effects/LightStreak/LightStreak.ps and b/WpfExtended/Effects/LightStreak/LightStreak.ps differ diff --git a/WpfExtended/Effects/Magnify/Magnify.ps b/WpfExtended/Effects/Magnify/Magnify.ps index 3a8a767..8fe54c4 100644 Binary files a/WpfExtended/Effects/Magnify/Magnify.ps and b/WpfExtended/Effects/Magnify/Magnify.ps differ diff --git a/WpfExtended/Effects/MonoChrome/Monochrome.ps b/WpfExtended/Effects/MonoChrome/Monochrome.ps index ef8936c..a5efb4f 100644 Binary files a/WpfExtended/Effects/MonoChrome/Monochrome.ps and b/WpfExtended/Effects/MonoChrome/Monochrome.ps differ diff --git a/WpfExtended/Effects/MotionBlur/MotionBlur.ps b/WpfExtended/Effects/MotionBlur/MotionBlur.ps index 2f92eff..4bb8ecc 100644 Binary files a/WpfExtended/Effects/MotionBlur/MotionBlur.ps and b/WpfExtended/Effects/MotionBlur/MotionBlur.ps differ diff --git a/WpfExtended/Effects/Negative/Negative.ps b/WpfExtended/Effects/Negative/Negative.ps index 027e032..861f4a2 100644 Binary files a/WpfExtended/Effects/Negative/Negative.ps and b/WpfExtended/Effects/Negative/Negative.ps differ diff --git a/WpfExtended/Effects/Pinch/Pinch.ps b/WpfExtended/Effects/Pinch/Pinch.ps index dc99482..9b982e2 100644 Binary files a/WpfExtended/Effects/Pinch/Pinch.ps and b/WpfExtended/Effects/Pinch/Pinch.ps differ diff --git a/WpfExtended/Effects/Pixelate/Pixelate.ps b/WpfExtended/Effects/Pixelate/Pixelate.ps index 5a5202c..e9fa599 100644 Binary files a/WpfExtended/Effects/Pixelate/Pixelate.ps and b/WpfExtended/Effects/Pixelate/Pixelate.ps differ diff --git a/WpfExtended/Effects/Ripple/Ripple.ps b/WpfExtended/Effects/Ripple/Ripple.ps index 185e6bc..25d41b3 100644 Binary files a/WpfExtended/Effects/Ripple/Ripple.ps and b/WpfExtended/Effects/Ripple/Ripple.ps differ diff --git a/WpfExtended/Effects/Sharpen/Sharpen.ps b/WpfExtended/Effects/Sharpen/Sharpen.ps index 32a9f4a..a4ac161 100644 Binary files a/WpfExtended/Effects/Sharpen/Sharpen.ps and b/WpfExtended/Effects/Sharpen/Sharpen.ps differ diff --git a/WpfExtended/Effects/SmoothMagnify/SmoothMagnify.ps b/WpfExtended/Effects/SmoothMagnify/SmoothMagnify.ps index 0138f2e..d93e909 100644 Binary files a/WpfExtended/Effects/SmoothMagnify/SmoothMagnify.ps and b/WpfExtended/Effects/SmoothMagnify/SmoothMagnify.ps differ diff --git a/WpfExtended/Effects/Swirl/Swirl.ps b/WpfExtended/Effects/Swirl/Swirl.ps index b93f682..91e0c6e 100644 Binary files a/WpfExtended/Effects/Swirl/Swirl.ps and b/WpfExtended/Effects/Swirl/Swirl.ps differ diff --git a/WpfExtended/Effects/ToneMapping/ToneMapping.ps b/WpfExtended/Effects/ToneMapping/ToneMapping.ps index 49910aa..2b2ca8b 100644 Binary files a/WpfExtended/Effects/ToneMapping/ToneMapping.ps and b/WpfExtended/Effects/ToneMapping/ToneMapping.ps differ diff --git a/WpfExtended/Effects/ToonShader/ToonShader.ps b/WpfExtended/Effects/ToonShader/ToonShader.ps index 2cad8e2..5b5d3c8 100644 Binary files a/WpfExtended/Effects/ToonShader/ToonShader.ps and b/WpfExtended/Effects/ToonShader/ToonShader.ps differ diff --git a/WpfExtended/Effects/ZoomBlur/ZoomBlur.ps b/WpfExtended/Effects/ZoomBlur/ZoomBlur.ps index c2871f0..4ad5505 100644 Binary files a/WpfExtended/Effects/ZoomBlur/ZoomBlur.ps and b/WpfExtended/Effects/ZoomBlur/ZoomBlur.ps differ diff --git a/WpfExtended/Launch/ExtendedApplication.cs b/WpfExtended/Launch/ExtendedApplication.cs index cf637ba..b5b799e 100644 --- a/WpfExtended/Launch/ExtendedApplication.cs +++ b/WpfExtended/Launch/ExtendedApplication.cs @@ -45,7 +45,6 @@ namespace System.Windows.Extensions this.SetupApplicationLifetime(); this.LaunchWindow(); } - protected sealed override void OnExit(ExitEventArgs e) { base.OnExit(e); diff --git a/WpfExtended/ShaderCompiler.target b/WpfExtended/ShaderCompiler.target index 42315a8..b22cd51 100644 --- a/WpfExtended/ShaderCompiler.target +++ b/WpfExtended/ShaderCompiler.target @@ -3,7 +3,7 @@ $(ProjectDir) $(SolutionDir)tools\fxc.exe - /O0 /T ps_2_0 /nologo /Fo + /O3 /T ps_3_0 /nologo /Fo diff --git a/WpfExtended/WpfExtended.csproj b/WpfExtended/WpfExtended.csproj index 91fc746..d5348c5 100644 --- a/WpfExtended/WpfExtended.csproj +++ b/WpfExtended/WpfExtended.csproj @@ -6,7 +6,8 @@ true true License.txt - 0.1.1 + 0.2.0 + latest Extension library for Windows Presentation Platform. Credits: @@ -28,6 +29,7 @@ http://www.java2s.com/Open-Source/CSharp_Free_Code/Windows_Presentation_Foundati + @@ -56,6 +58,7 @@ http://www.java2s.com/Open-Source/CSharp_Free_Code/Windows_Presentation_Foundati +