├── .gitattributes ├── .gitignore ├── BackgroundEffectBehavior.png ├── BlendModes.psd ├── BlendModes2.psd ├── BlendModesOpacityTester.psd ├── ColorPicker ├── ColorPicker.cs ├── ColorPicker.csproj ├── ColorPicker.csproj.vspscc ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings └── Themes │ └── Generic.xaml ├── H.design ├── HOnImage.png ├── HOnImage600.png ├── HOnImageColorBurn.png ├── HOnImageColorBurn600.png ├── HOnImageColorBurn600NoCigar.png ├── HOnImageColorBurn600Success.png ├── HelloWorld.design ├── HelloWorldColorBurn600.png ├── Microsoft.DwayneNeed ├── Controls │ ├── VisualTargetPresentationSource.cs │ └── VisualWrapper.cs ├── CustomControl1.cs ├── Media │ └── Imaging │ │ ├── Bgra32Pixel.cs │ │ ├── ChainedBitmap.cs │ │ ├── ColorKeyBitmap.cs │ │ ├── CustomBitmap.cs │ │ ├── GrayscaleBitmap.cs │ │ └── SepiaBitmap.cs ├── Microsoft.DwayneNeed.csproj ├── Microsoft.DwayneNeed.csproj.vspscc ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings └── Themes │ └── Generic.xaml ├── PhotoshopMathFP.hlsl ├── README.markdown ├── WPFBlendModeEffectLibrary ├── EffectFiles │ ├── AverageEffect.cs │ ├── BlendModeEffect.cs │ ├── ColorBurnEffect.cs │ ├── ColorDodgeEffect.cs │ ├── ColorEffect.cs │ ├── DarkenEffect.cs │ ├── DifferenceEffect.cs │ ├── ExclusionEffect.cs │ ├── GlowEffect.cs │ ├── HardLightEffect.cs │ ├── HardMixEffect.cs │ ├── HueEffect.cs │ ├── LightenEffect.cs │ ├── LinearBurnEffect.cs │ ├── LinearDodgeEffect.cs │ ├── LinearLightEffect.cs │ ├── LuminosityEffect.cs │ ├── MultiplyEffect.cs │ ├── NegationEffect.cs │ ├── NormalEffect.cs │ ├── OverlayEffect.cs │ ├── PhoenixEffect.cs │ ├── PinLightEffect.cs │ ├── ReflectEffect.cs │ ├── SaturationEffect.cs │ ├── ScreenEffect.cs │ ├── SoftLightEffect.cs │ └── VividLightEffect.cs ├── EffectLibrary.cs ├── Properties │ └── AssemblyInfo.cs ├── ShaderSource │ ├── AverageEffect.fx │ ├── AverageEffect.ps │ ├── ColorBurnEffect.fx │ ├── ColorBurnEffect.ps │ ├── ColorDodgeEffect.fx │ ├── ColorDodgeEffect.ps │ ├── ColorEffect.fx │ ├── ColorEffect.ps │ ├── DarkenEffect.fx │ ├── DarkenEffect.ps │ ├── DifferenceEffect.fx │ ├── DifferenceEffect.ps │ ├── ExclusionEffect.fx │ ├── ExclusionEffect.ps │ ├── GlowEffect.fx │ ├── GlowEffect.ps │ ├── HardLightEffect.fx │ ├── HardLightEffect.ps │ ├── HardMixEffect.fx │ ├── HardMixEffect.ps │ ├── HueEffect.fx │ ├── HueEffect.ps │ ├── LightenEffect.fx │ ├── LightenEffect.ps │ ├── LinearBurnEffect.fx │ ├── LinearBurnEffect.ps │ ├── LinearDodgeEffect.fx │ ├── LinearDodgeEffect.ps │ ├── LinearLightEffect.fx │ ├── LinearLightEffect.ps │ ├── LuminosityEffect.fx │ ├── LuminosityEffect.ps │ ├── MultiplyEffect.fx │ ├── MultiplyEffect.ps │ ├── NegationEffect.fx │ ├── NegationEffect.ps │ ├── NormalEffect.fx │ ├── NormalEffect.ps │ ├── OverlayEffect.fx │ ├── OverlayEffect.ps │ ├── PhoenixEffect.fx │ ├── PhoenixEffect.ps │ ├── PinLightEffect.fx │ ├── PinLightEffect.ps │ ├── ReflectEffect.fx │ ├── ReflectEffect.ps │ ├── SaturationEffect.fx │ ├── SaturationEffect.ps │ ├── ScreenEffect.fx │ ├── ScreenEffect.ps │ ├── SoftLightEffect.fx │ ├── SoftLightEffect.ps │ ├── VividLightEffect.fx │ └── VividLightEffect.ps ├── WPFBlendModeEffectLibrary.csproj └── WPFBlendModeEffectLibrary.csproj.vspscc ├── WPFSLBlendModeFx.sln ├── WPFSLBlendModeFx.vssscc └── WPFTestHarness ├── App.xaml ├── App.xaml.cs ├── BackgroundEffectBehavior.cs ├── BlueBulbWindow.xaml ├── BlueBulbWindow.xaml.cs ├── GradientContoursTestWindow.xaml ├── GradientContoursTestWindow.xaml.cs ├── GradientTestWindow.xaml ├── GradientTestWindow.xaml.cs ├── Grayscale4Bitmap.cs ├── HelloWorldTestWindow.xaml ├── HelloWorldTestWindow.xaml.cs ├── HelloWorldVideoTestWindow.xaml ├── HelloWorldVideoTestWindow.xaml.cs ├── ImageTestWindow.xaml ├── ImageTestWindow.xaml.cs ├── LinearBurnTestWindow.xaml ├── LinearBurnTestWindow.xaml.cs ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── Properties ├── AssemblyInfo.cs ├── Resources.Designer.cs ├── Resources.resx ├── Settings.Designer.cs └── Settings.settings ├── RedBulbWindow.xaml ├── RedBulbWindow.xaml.cs ├── Resources ├── MSwanson - Wide - Water 06.jpg ├── Wildlife.wmv ├── fall_325x244.jpg ├── image1_325x244.jpg ├── image2_325x244.jpg ├── summer_325x244.jpg ├── texture1_325x244.jpg └── texture2_325x244.jpg ├── WPFTestHarness.csproj ├── WPFTestHarness.csproj.vspscc └── app.config /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vs/ 2 | obj/ 3 | bin/ 4 | *.suo 5 | WPFBlendModeEffectLibrary/ShaderSource/AverageEffect.ps 6 | WPFBlendModeEffectLibrary/ShaderSource/ColorBurnEffect.ps 7 | WPFBlendModeEffectLibrary/ShaderSource/ColorDodgeEffect.ps 8 | WPFBlendModeEffectLibrary/ShaderSource/DarkenEffect.ps 9 | WPFBlendModeEffectLibrary/ShaderSource/DifferenceEffect.ps 10 | WPFBlendModeEffectLibrary/ShaderSource/ExclusionEffect.ps 11 | WPFBlendModeEffectLibrary/ShaderSource/GlowEffect.ps 12 | WPFBlendModeEffectLibrary/ShaderSource/HardLightEffect.ps 13 | WPFBlendModeEffectLibrary/ShaderSource/HardMixEffect.ps 14 | WPFBlendModeEffectLibrary/ShaderSource/LightenEffect.ps 15 | WPFBlendModeEffectLibrary/ShaderSource/LinearBurnEffect.ps 16 | WPFBlendModeEffectLibrary/ShaderSource/LinearDodgeEffect.ps 17 | WPFBlendModeEffectLibrary/ShaderSource/LinearLightEffect.ps 18 | WPFBlendModeEffectLibrary/ShaderSource/MultiplyEffect.ps 19 | WPFBlendModeEffectLibrary/ShaderSource/NegationEffect.ps 20 | WPFBlendModeEffectLibrary/ShaderSource/NormalEffect.ps 21 | WPFBlendModeEffectLibrary/ShaderSource/OverlayEffect.ps 22 | WPFBlendModeEffectLibrary/ShaderSource/PhoenixEffect.ps 23 | WPFBlendModeEffectLibrary/ShaderSource/PinLightEffect.ps 24 | WPFBlendModeEffectLibrary/ShaderSource/ReflectEffect.ps 25 | WPFBlendModeEffectLibrary/ShaderSource/ScreenEffect.ps 26 | WPFBlendModeEffectLibrary/ShaderSource/SoftLightEffect.ps 27 | WPFBlendModeEffectLibrary/ShaderSource/VividLightEffect.ps 28 | -------------------------------------------------------------------------------- /BackgroundEffectBehavior.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/BackgroundEffectBehavior.png -------------------------------------------------------------------------------- /BlendModes.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/BlendModes.psd -------------------------------------------------------------------------------- /BlendModes2.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/BlendModes2.psd -------------------------------------------------------------------------------- /BlendModesOpacityTester.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/BlendModesOpacityTester.psd -------------------------------------------------------------------------------- /ColorPicker/ColorPicker.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.30729 7 | 2.0 8 | {ED67A75F-5F76-43A8-9CD0-171212D599CB} 9 | library 10 | Properties 11 | ColorPicker 12 | ColorPicker 13 | v4.8 14 | 512 15 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 16 | 4 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 3.5 28 | 29 | publish\ 30 | true 31 | Disk 32 | false 33 | Foreground 34 | 7 35 | Days 36 | false 37 | false 38 | true 39 | 0 40 | 1.0.0.%2a 41 | false 42 | false 43 | true 44 | 45 | 46 | 47 | true 48 | full 49 | false 50 | bin\Debug\ 51 | DEBUG;TRACE 52 | prompt 53 | 4 54 | AllRules.ruleset 55 | false 56 | 57 | 58 | pdbonly 59 | true 60 | bin\Release\ 61 | TRACE 62 | prompt 63 | 4 64 | AllRules.ruleset 65 | false 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | MSBuild:Compile 79 | Designer 80 | MSBuild:Compile 81 | Designer 82 | 83 | 84 | Code 85 | 86 | 87 | 88 | 89 | Code 90 | 91 | 92 | True 93 | True 94 | Resources.resx 95 | 96 | 97 | True 98 | Settings.settings 99 | True 100 | 101 | 102 | ResXFileCodeGenerator 103 | Resources.Designer.cs 104 | Designer 105 | 106 | 107 | SettingsSingleFileGenerator 108 | Settings.Designer.cs 109 | 110 | 111 | 112 | 113 | 114 | False 115 | .NET Framework 3.5 SP1 Client Profile 116 | false 117 | 118 | 119 | False 120 | .NET Framework 3.5 SP1 121 | true 122 | 123 | 124 | False 125 | Microsoft Visual Basic PowerPacks 10.0 126 | true 127 | 128 | 129 | False 130 | Windows Installer 3.1 131 | true 132 | 133 | 134 | 135 | 142 | -------------------------------------------------------------------------------- /ColorPicker/ColorPicker.csproj.vspscc: -------------------------------------------------------------------------------- 1 | "" 2 | { 3 | "FILE_VERSION" = "9237" 4 | "ENLISTMENT_CHOICE" = "NEVER" 5 | "PROJECT_FILE_RELATIVE_PATH" = "" 6 | "NUMBER_OF_EXCLUDED_FILES" = "0" 7 | "ORIGINAL_PROJECT_FILE_PATH" = "" 8 | "NUMBER_OF_NESTED_PROJECTS" = "0" 9 | "SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" 10 | } 11 | -------------------------------------------------------------------------------- /ColorPicker/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("ColorPicker")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("Starkey Laboratories")] 14 | [assembly: AssemblyProduct("ColorPicker")] 15 | [assembly: AssemblyCopyright("Copyright © Starkey Laboratories 2008")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | //In order to begin building localizable applications, set 25 | //CultureYouAreCodingWith in your .csproj file 26 | //inside a . For example, if you are using US english 27 | //in your source files, set the to en-US. Then uncomment 28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 29 | //the line below to match the UICulture setting in the project file. 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 36 | //(used if a resource is not found in the page, 37 | // or application resource dictionaries) 38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 39 | //(used if a resource is not found in the page, 40 | // app, or any theme specific resource dictionaries) 41 | )] 42 | 43 | 44 | // Version information for an assembly consists of the following four values: 45 | // 46 | // Major Version 47 | // Minor Version 48 | // Build Number 49 | // Revision 50 | // 51 | // You can specify all the values or you can default the Build and Revision Numbers 52 | // by using the '*' as shown below: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.0.0.0")] 55 | [assembly: AssemblyFileVersion("1.0.0.0")] 56 | -------------------------------------------------------------------------------- /ColorPicker/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace ColorPicker.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ColorPicker.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /ColorPicker/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /ColorPicker/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace ColorPicker.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.11.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /ColorPicker/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /ColorPicker/Themes/Generic.xaml: -------------------------------------------------------------------------------- 1 |  6 | 9 | 10 | 13 | 14 | 25 | 26 | 119 | 120 | -------------------------------------------------------------------------------- /H.design: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/H.design -------------------------------------------------------------------------------- /HOnImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/HOnImage.png -------------------------------------------------------------------------------- /HOnImage600.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/HOnImage600.png -------------------------------------------------------------------------------- /HOnImageColorBurn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/HOnImageColorBurn.png -------------------------------------------------------------------------------- /HOnImageColorBurn600.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/HOnImageColorBurn600.png -------------------------------------------------------------------------------- /HOnImageColorBurn600NoCigar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/HOnImageColorBurn600NoCigar.png -------------------------------------------------------------------------------- /HOnImageColorBurn600Success.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/HOnImageColorBurn600Success.png -------------------------------------------------------------------------------- /HelloWorld.design: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/HelloWorld.design -------------------------------------------------------------------------------- /HelloWorldColorBurn600.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/HelloWorldColorBurn600.png -------------------------------------------------------------------------------- /Microsoft.DwayneNeed/Controls/VisualTargetPresentationSource.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Windows; 5 | using System.Windows.Media; 6 | 7 | namespace Microsoft.DwayneNeed.Controls 8 | { 9 | /// 10 | /// The VisualTargetPresentationSource represents the root 11 | /// of a visual subtree owned by a different thread that the 12 | /// visual tree in which is is displayed. 13 | /// 14 | /// 15 | /// A HostVisual belongs to the same UI thread that owns the 16 | /// visual tree in which it resides. 17 | /// 18 | /// A HostVisual can reference a VisualTarget owned by another 19 | /// thread. 20 | /// 21 | /// A VisualTarget has a root visual. 22 | /// 23 | /// VisualTargetPresentationSource wraps the VisualTarget and 24 | /// enables basic functionality like Loaded, which depends on 25 | /// a PresentationSource being available. 26 | /// 27 | public class VisualTargetPresentationSource : PresentationSource 28 | { 29 | public VisualTargetPresentationSource(HostVisual hostVisual) 30 | { 31 | _visualTarget = new VisualTarget(hostVisual); 32 | } 33 | 34 | public override Visual RootVisual 35 | { 36 | get 37 | { 38 | return _visualTarget.RootVisual; 39 | } 40 | 41 | set 42 | { 43 | Visual oldRoot = _visualTarget.RootVisual; 44 | 45 | // Set the root visual of the VisualTarget. This visual will 46 | // now be used to visually compose the scene. 47 | _visualTarget.RootVisual = value; 48 | 49 | // Tell the PresentationSource that the root visual has 50 | // changed. This kicks off a bunch of stuff like the 51 | // Loaded event. 52 | RootChanged(oldRoot, value); 53 | 54 | // Kickoff layout... 55 | UIElement rootElement = value as UIElement; 56 | if (rootElement != null) 57 | { 58 | rootElement.Measure(new Size(Double.PositiveInfinity, 59 | Double.PositiveInfinity)); 60 | rootElement.Arrange(new Rect(rootElement.DesiredSize)); 61 | } 62 | } 63 | } 64 | 65 | protected override CompositionTarget GetCompositionTargetCore() 66 | { 67 | return _visualTarget; 68 | } 69 | 70 | public override bool IsDisposed 71 | { 72 | get 73 | { 74 | // We don't support disposing this object. 75 | return false; 76 | } 77 | } 78 | 79 | private VisualTarget _visualTarget; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Microsoft.DwayneNeed/Controls/VisualWrapper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Windows.Markup; 5 | using System.Windows; 6 | using System.Windows.Media; 7 | 8 | namespace Microsoft.DwayneNeed.Controls 9 | { 10 | /// 11 | /// The VisualWrapper simply integrates a raw Visual child into a tree 12 | /// of FrameworkElements. 13 | /// 14 | [ContentProperty("Child")] 15 | public class VisualWrapper : FrameworkElement 16 | { 17 | public Visual Child 18 | { 19 | get 20 | { 21 | return _child; 22 | } 23 | 24 | set 25 | { 26 | if (_child != null) 27 | { 28 | RemoveVisualChild(_child); 29 | } 30 | 31 | _child = value; 32 | 33 | if (_child != null) 34 | { 35 | AddVisualChild(_child); 36 | } 37 | } 38 | } 39 | 40 | protected override Visual GetVisualChild(int index) 41 | { 42 | if (_child != null && index == 0) 43 | { 44 | return _child; 45 | } 46 | else 47 | { 48 | throw new ArgumentOutOfRangeException("index"); 49 | } 50 | } 51 | 52 | protected override int VisualChildrenCount 53 | { 54 | get 55 | { 56 | return _child != null ? 1 : 0; 57 | } 58 | } 59 | 60 | private Visual _child; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Microsoft.DwayneNeed/CustomControl1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Windows; 5 | using System.Windows.Controls; 6 | using System.Windows.Data; 7 | using System.Windows.Documents; 8 | using System.Windows.Input; 9 | using System.Windows.Media; 10 | using System.Windows.Media.Imaging; 11 | using System.Windows.Navigation; 12 | using System.Windows.Shapes; 13 | 14 | namespace Microsoft.DwayneNeed 15 | { 16 | /// 17 | /// Follow steps 1a or 1b and then 2 to use this custom control in a XAML file. 18 | /// 19 | /// Step 1a) Using this custom control in a XAML file that exists in the current project. 20 | /// Add this XmlNamespace attribute to the root element of the markup file where it is 21 | /// to be used: 22 | /// 23 | /// xmlns:MyNamespace="clr-namespace:Microsoft.DwayneNeed" 24 | /// 25 | /// 26 | /// Step 1b) Using this custom control in a XAML file that exists in a different project. 27 | /// Add this XmlNamespace attribute to the root element of the markup file where it is 28 | /// to be used: 29 | /// 30 | /// xmlns:MyNamespace="clr-namespace:Microsoft.DwayneNeed;assembly=Microsoft.DwayneNeed" 31 | /// 32 | /// You will also need to add a project reference from the project where the XAML file lives 33 | /// to this project and Rebuild to avoid compilation errors: 34 | /// 35 | /// Right click on the target project in the Solution Explorer and 36 | /// "Add Reference"->"Projects"->[Select this project] 37 | /// 38 | /// 39 | /// Step 2) 40 | /// Go ahead and use your control in the XAML file. 41 | /// 42 | /// 43 | /// 44 | /// 45 | public class CustomControl1 : Control 46 | { 47 | static CustomControl1() 48 | { 49 | DefaultStyleKeyProperty.OverrideMetadata(typeof(CustomControl1), new FrameworkPropertyMetadata(typeof(CustomControl1))); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Microsoft.DwayneNeed/Media/Imaging/Bgra32Pixel.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.DwayneNeed.Media.Imaging 2 | { 3 | /// 4 | /// The Bgra32Pixel struct defines the memory layout of a Bgra32 pixel. 5 | /// 6 | public struct Bgra32Pixel 7 | { 8 | public byte Blue; 9 | public byte Green; 10 | public byte Red; 11 | public byte Alpha; 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /Microsoft.DwayneNeed/Media/Imaging/ColorKeyBitmap.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | using System.Windows.Media.Imaging; 5 | 6 | namespace Microsoft.DwayneNeed.Media.Imaging 7 | { 8 | /// 9 | /// The ColorKeyBitmap class processes a source and produces 10 | /// Bgra32 bits, where all source pixels are opaque except for one 11 | /// color that is transparent. 12 | /// 13 | /// 14 | /// For simplicity, we only process Bgra32 formatted bitmaps, anything 15 | /// else is converted to that format. Converting a pixel format that 16 | /// does not have an alpha channel to Bgra32 simply creates an opaque 17 | /// alpha value. ColorKeyBitmap then changes the alpha channel for 18 | /// pixels that match the transparent color. 19 | /// 20 | public class ColorKeyBitmap : ChainedBitmap 21 | { 22 | #region TransparentColor 23 | 24 | /// 25 | /// The DependencyProperty for the TransparentColor property. 26 | /// 27 | public static readonly DependencyProperty TransparentColorProperty = 28 | DependencyProperty.Register("TransparentColor", 29 | typeof(Color?), 30 | typeof(ColorKeyBitmap), 31 | new FrameworkPropertyMetadata( 32 | null, 33 | null, 34 | null)); 35 | 36 | /// 37 | /// The color to make transparent. 38 | /// 39 | public Color? TransparentColor 40 | { 41 | get 42 | { 43 | return (Color?)GetValue(TransparentColorProperty); 44 | } 45 | 46 | set 47 | { 48 | SetValue(TransparentColorProperty, value); 49 | } 50 | } 51 | 52 | #endregion TransparentColor 53 | 54 | #region BitmapSource Properties 55 | 56 | /// 57 | /// Pixel format of the bitmap. 58 | /// 59 | /// 60 | /// ColorKeyBitmap will only work natively with Bgra32. 61 | /// 62 | public sealed override PixelFormat Format 63 | { 64 | get 65 | { 66 | return PixelFormats.Bgra32; 67 | } 68 | } 69 | 70 | /// 71 | /// Palette of the bitmap. 72 | /// 73 | /// 74 | /// We only support Bgra32, so a palette is never needed, so we 75 | /// return null. 76 | /// 77 | public override BitmapPalette Palette 78 | { 79 | get 80 | { 81 | return null; 82 | } 83 | } 84 | 85 | #endregion BitmapSource Properties 86 | 87 | #region BitmapSource CopyPixels 88 | 89 | /// 90 | /// Requests pixels from the ChainedCustomBitmapSource. 91 | /// 92 | /// 93 | /// The rectangle of pixels being requested. 94 | /// 95 | /// 96 | /// The stride of the destination buffer. 97 | /// 98 | /// 99 | /// The size of the destination buffer. 100 | /// 101 | /// 102 | /// The destination buffer. 103 | /// 104 | /// 105 | /// The default implementation simply calls CopyPixels on the 106 | /// source. 107 | /// 108 | protected override void CopyPixelsCore(Int32Rect sourceRect, int stride, int bufferSize, IntPtr buffer) 109 | { 110 | BitmapSource source = Source; 111 | if (source != null) 112 | { 113 | // First defer to the base implementation, which will fill in 114 | // the buffer from the source and convert the pixel format as 115 | // needed. 116 | base.CopyPixelsCore(sourceRect, stride, bufferSize, buffer); 117 | 118 | // Also fetch the color of the upper-left corner (0,0) if the 119 | // transparent color has not been specified. 120 | Color transparentColor; 121 | if (TransparentColor == null) 122 | { 123 | uint[] firstPixel = new uint[1]; 124 | 125 | unsafe 126 | { 127 | fixed (uint* pFirstPixel = firstPixel) 128 | { 129 | base.CopyPixelsCore(new Int32Rect(0, 0, 1, 1), 4, 4, new IntPtr(pFirstPixel)); 130 | 131 | Bgra32Pixel* pBgraPixel = (Bgra32Pixel*)pFirstPixel; 132 | transparentColor = Color.FromRgb(pBgraPixel->Red, 133 | pBgraPixel->Green, 134 | pBgraPixel->Blue); 135 | } 136 | } 137 | } 138 | else 139 | { 140 | transparentColor = TransparentColor.Value; 141 | } 142 | 143 | // The buffer has been filled with Bgr32 or Bgra32 pixels. 144 | // Now process these pixels and set the alpha channel to 0 for 145 | // pixels that match the color key. Leave the other pixels 146 | // alone. 147 | // 148 | // Note: if this buffer pointer came from a managed array, the 149 | // array has already been pinned. 150 | unsafe 151 | { 152 | byte* pBytes = (byte*)buffer.ToPointer(); 153 | for (int y = 0; y < sourceRect.Height; y++) 154 | { 155 | Bgra32Pixel* pPixel = (Bgra32Pixel*)pBytes; 156 | 157 | for (int x = 0; x < sourceRect.Width; x++) 158 | { 159 | if (pPixel->Red == transparentColor.R && 160 | pPixel->Green == transparentColor.G && 161 | pPixel->Blue == transparentColor.B) 162 | { 163 | pPixel->Alpha = 0x00; 164 | } 165 | 166 | pPixel++; 167 | } 168 | 169 | pBytes += stride; 170 | } 171 | } 172 | } 173 | } 174 | 175 | #endregion BitmapSource CopyPixels 176 | } 177 | } 178 | -------------------------------------------------------------------------------- /Microsoft.DwayneNeed/Media/Imaging/GrayscaleBitmap.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | using System.Windows.Media.Imaging; 5 | 6 | namespace Microsoft.DwayneNeed.Media.Imaging 7 | { 8 | /// 9 | /// The GrayscaleBitmap class processes a source and converts the 10 | /// image to a grayscale color scheme. 11 | /// 12 | /// 13 | /// For simplicity, we only process Bgr32 or Bgra32 formatted bitmaps, 14 | /// anything else is converted to one of those formats. Bgr32 and 15 | /// Bgra32 share the same memory layout for the RGB channels. 16 | /// 17 | public class GrayscaleBitmap : ChainedBitmap 18 | { 19 | #region BitmapSource Properties 20 | 21 | /// 22 | /// Pixel format of the bitmap. 23 | /// 24 | /// 25 | /// We will work natively with either Bgr32 or Bgra32, since both 26 | /// formats have the same memory layout. 27 | /// 28 | public sealed override PixelFormat Format 29 | { 30 | get 31 | { 32 | // Preserve an alpha channel, if there is one. 33 | PixelFormat format = base.Format; 34 | if (format == PixelFormats.Bgra32 || 35 | format == PixelFormats.Prgba64 || 36 | format == PixelFormats.Pbgra32 || 37 | format == PixelFormats.Prgba128Float || 38 | format == PixelFormats.Rgba128Float || 39 | format == PixelFormats.Rgba64) 40 | { 41 | format = PixelFormats.Bgra32; 42 | } 43 | else 44 | { 45 | format = PixelFormats.Bgr32; 46 | } 47 | 48 | return format; 49 | } 50 | } 51 | 52 | /// 53 | /// Palette of the bitmap. 54 | /// 55 | /// 56 | /// We only support Bgr32 and Bgra32 pixel formats, so a palette 57 | /// is never needed, so we return null. 58 | /// 59 | public override BitmapPalette Palette 60 | { 61 | get 62 | { 63 | return null; 64 | } 65 | } 66 | 67 | #endregion BitmapSource Properties 68 | 69 | #region BitmapSource CopyPixels 70 | 71 | /// 72 | /// Requests pixels from the ChainedCustomBitmapSource. 73 | /// 74 | /// 75 | /// The rectangle of pixels being requested. 76 | /// 77 | /// 78 | /// The stride of the destination buffer. 79 | /// 80 | /// 81 | /// The size of the destination buffer. 82 | /// 83 | /// 84 | /// The destination buffer. 85 | /// 86 | /// 87 | /// Converts the contents of the source bitmap into a grayscale 88 | /// color scheme. 89 | /// 90 | /// The algorithm is taken from here: 91 | /// http://en.wikipedia.org/wiki/Grayscale 92 | /// 93 | protected override void CopyPixelsCore(Int32Rect sourceRect, int stride, int bufferSize, IntPtr buffer) 94 | { 95 | BitmapSource source = Source; 96 | if (source != null) 97 | { 98 | // First defer to the base implementation, which will fill in 99 | // the buffer from the source and convert the pixel format as 100 | // needed. 101 | base.CopyPixelsCore(sourceRect, stride, bufferSize, buffer); 102 | 103 | // The buffer has been filled with Bgr32 or Bgra32 pixels. 104 | // Now process those pixels into grayscale. Ignore the 105 | // alpha channel. 106 | // 107 | // Note: if this buffer pointer came from a managed array, the 108 | // array has already been pinned. 109 | unsafe 110 | { 111 | byte* pBytes = (byte*)buffer.ToPointer(); 112 | for (int y = 0; y < sourceRect.Height; y++) 113 | { 114 | Bgra32Pixel* pPixel = (Bgra32Pixel*)pBytes; 115 | 116 | for (int x = 0; x < sourceRect.Width; x++) 117 | { 118 | // Get the linear color space values of this pixel. 119 | Color c = Color.FromRgb(pPixel->Red, pPixel->Green, pPixel->Blue); 120 | float red = c.ScR; 121 | float green = c.ScG; 122 | float blue = c.ScB; 123 | 124 | // Calculate the grayscale equivalent, taking into account 125 | // the sensitivity of the human eye to the different primary 126 | // colors (less sensitive to blue, more to green). 127 | float gray = red * 0.30f + green * 0.59f + blue * 0.11f; 128 | 129 | Color cGray = Color.FromScRgb(1.0f, gray, gray, gray); 130 | 131 | // Write sRGB (non-linear) since it is implied by 132 | // the pixel format we chose. 133 | pPixel->Red = cGray.R; 134 | pPixel->Green = cGray.G; 135 | pPixel->Blue = cGray.B; 136 | 137 | pPixel++; 138 | } 139 | 140 | pBytes += stride; 141 | } 142 | } 143 | } 144 | } 145 | 146 | #endregion BitmapSource CopyPixels 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /Microsoft.DwayneNeed/Media/Imaging/SepiaBitmap.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | using System.Windows.Media.Imaging; 5 | 6 | namespace Microsoft.DwayneNeed.Media.Imaging 7 | { 8 | /// 9 | /// The SepiaBitmap class processes a source and converts the 10 | /// image to a sepia color scheme. 11 | /// 12 | /// 13 | /// For simplicity, we only process Bgr32 or Bgra32 formatted bitmaps, 14 | /// anything else is converted to one of those formats. Bgr32 and 15 | /// Bgra32 share the same memory layout for the RGB channels. 16 | /// 17 | public class SepiaBitmap : ChainedBitmap 18 | { 19 | #region BitmapSource Properties 20 | 21 | /// 22 | /// Pixel format of the bitmap. 23 | /// 24 | /// 25 | /// We will work natively with either Bgr32 or Bgra32, since both 26 | /// formats have the same memory layout. 27 | /// 28 | public sealed override PixelFormat Format 29 | { 30 | get 31 | { 32 | // Preserve an alpha channel, if there is one. 33 | PixelFormat format = base.Format; 34 | if (format == PixelFormats.Bgra32 || 35 | format == PixelFormats.Prgba64 || 36 | format == PixelFormats.Pbgra32 || 37 | format == PixelFormats.Prgba128Float || 38 | format == PixelFormats.Rgba128Float || 39 | format == PixelFormats.Rgba64) 40 | { 41 | format = PixelFormats.Bgra32; 42 | } 43 | else 44 | { 45 | format = PixelFormats.Bgr32; 46 | } 47 | 48 | return format; 49 | } 50 | } 51 | 52 | /// 53 | /// Palette of the bitmap. 54 | /// 55 | /// 56 | /// We only support Bgr32 and Bgra32 pixel formats, so a palette 57 | /// is never needed, so we return null. 58 | /// 59 | public override BitmapPalette Palette 60 | { 61 | get 62 | { 63 | return null; 64 | } 65 | } 66 | 67 | #endregion BitmapSource Properties 68 | 69 | #region BitmapSource CopyPixels 70 | 71 | /// 72 | /// Requests pixels from the ChainedCustomBitmapSource. 73 | /// 74 | /// 75 | /// The rectangle of pixels being requested. 76 | /// 77 | /// 78 | /// The stride of the destination buffer. 79 | /// 80 | /// 81 | /// The size of the destination buffer. 82 | /// 83 | /// 84 | /// The destination buffer. 85 | /// 86 | /// 87 | /// Converts the contents of the source bitmap into a sepia color 88 | /// scheme. 89 | /// 90 | /// The algorithm is taken from here: 91 | /// http://msdn.microsoft.com/en-us/magazine/cc163866.aspx 92 | /// 93 | protected override void CopyPixelsCore(Int32Rect sourceRect, int stride, int bufferSize, IntPtr buffer) 94 | { 95 | BitmapSource source = Source; 96 | if (source != null) 97 | { 98 | // First defer to the base implementation, which will fill in 99 | // the buffer from the source and convert the pixel format as 100 | // needed. 101 | base.CopyPixelsCore(sourceRect, stride, bufferSize, buffer); 102 | 103 | // The buffer has been filled with Bgr32 or Bgra32 pixels. 104 | // Now process those pixels into a sepia tint. Ignore the 105 | // alpha channel. 106 | // 107 | // Note: if this buffer pointer came from a managed array, the 108 | // array has already been pinned. 109 | unsafe 110 | { 111 | byte* pBytes = (byte*)buffer.ToPointer(); 112 | for (int y = 0; y < sourceRect.Height; y++) 113 | { 114 | Bgra32Pixel* pPixel = (Bgra32Pixel*)pBytes; 115 | 116 | for (int x = 0; x < sourceRect.Width; x++) 117 | { 118 | // Get the linear color space values of this pixel. 119 | Color c = Color.FromRgb(pPixel->Red, pPixel->Green, pPixel->Blue); 120 | float red = c.ScR; 121 | float green = c.ScG; 122 | float blue = c.ScB; 123 | 124 | Color cSepia = Color.FromScRgb(1.0f, 125 | red * 0.393f + green * 0.769f + blue * 0.189f, 126 | red * 0.349f + green * 0.686f + blue * 0.168f, 127 | red * 0.272f + green * 0.534f + blue * 0.131f); 128 | 129 | 130 | // Write sRGB (non-linear) since it is implied by 131 | // the pixel format we chose. 132 | pPixel->Red = cSepia.R; 133 | pPixel->Green = cSepia.G; 134 | pPixel->Blue = cSepia.B; 135 | 136 | pPixel++; 137 | } 138 | 139 | pBytes += stride; 140 | } 141 | } 142 | } 143 | } 144 | 145 | #endregion BitmapSource CopyPixels 146 | } 147 | } 148 | -------------------------------------------------------------------------------- /Microsoft.DwayneNeed/Microsoft.DwayneNeed.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.30609 7 | 2.0 8 | {80A10B86-6615-4440-93B0-C943DF5B8693} 9 | library 10 | Properties 11 | Microsoft.DwayneNeed 12 | Microsoft.DwayneNeed 13 | v4.8 14 | 512 15 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 16 | 4 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 3.5 28 | 29 | publish\ 30 | true 31 | Disk 32 | false 33 | Foreground 34 | 7 35 | Days 36 | false 37 | false 38 | true 39 | 0 40 | 1.0.0.%2a 41 | false 42 | false 43 | true 44 | 45 | 46 | 47 | true 48 | full 49 | false 50 | bin\Debug\ 51 | DEBUG;TRACE 52 | prompt 53 | 4 54 | true 55 | AllRules.ruleset 56 | false 57 | 58 | 59 | pdbonly 60 | true 61 | bin\Release\ 62 | TRACE 63 | prompt 64 | 4 65 | true 66 | AllRules.ruleset 67 | false 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | MSBuild:Compile 81 | Designer 82 | MSBuild:Compile 83 | Designer 84 | 85 | 86 | Code 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | Code 100 | 101 | 102 | True 103 | True 104 | Resources.resx 105 | 106 | 107 | True 108 | Settings.settings 109 | True 110 | 111 | 112 | ResXFileCodeGenerator 113 | Resources.Designer.cs 114 | 115 | 116 | SettingsSingleFileGenerator 117 | Settings.Designer.cs 118 | 119 | 120 | 121 | 122 | 123 | False 124 | .NET Framework 3.5 SP1 Client Profile 125 | false 126 | 127 | 128 | False 129 | .NET Framework 3.5 SP1 130 | true 131 | 132 | 133 | False 134 | Microsoft Visual Basic PowerPacks 10.0 135 | true 136 | 137 | 138 | False 139 | Windows Installer 3.1 140 | true 141 | 142 | 143 | 144 | 151 | -------------------------------------------------------------------------------- /Microsoft.DwayneNeed/Microsoft.DwayneNeed.csproj.vspscc: -------------------------------------------------------------------------------- 1 | "" 2 | { 3 | "FILE_VERSION" = "9237" 4 | "ENLISTMENT_CHOICE" = "NEVER" 5 | "PROJECT_FILE_RELATIVE_PATH" = "" 6 | "NUMBER_OF_EXCLUDED_FILES" = "0" 7 | "ORIGINAL_PROJECT_FILE_PATH" = "" 8 | "NUMBER_OF_NESTED_PROJECTS" = "0" 9 | "SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" 10 | } 11 | -------------------------------------------------------------------------------- /Microsoft.DwayneNeed/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("Microsoft.DwayneNeed")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("Microsoft")] 14 | [assembly: AssemblyProduct("Microsoft.DwayneNeed")] 15 | [assembly: AssemblyCopyright("Copyright © Microsoft 2008")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | //In order to begin building localizable applications, set 25 | //CultureYouAreCodingWith in your .csproj file 26 | //inside a . For example, if you are using US english 27 | //in your source files, set the to en-US. Then uncomment 28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 29 | //the line below to match the UICulture setting in the project file. 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 36 | //(used if a resource is not found in the page, 37 | // or application resource dictionaries) 38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 39 | //(used if a resource is not found in the page, 40 | // app, or any theme specific resource dictionaries) 41 | )] 42 | 43 | 44 | // Version information for an assembly consists of the following four values: 45 | // 46 | // Major Version 47 | // Minor Version 48 | // Build Number 49 | // Revision 50 | // 51 | // You can specify all the values or you can default the Build and Revision Numbers 52 | // by using the '*' as shown below: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.0.0.0")] 55 | [assembly: AssemblyFileVersion("1.0.0.0")] 56 | -------------------------------------------------------------------------------- /Microsoft.DwayneNeed/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Microsoft.DwayneNeed.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.DwayneNeed.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Microsoft.DwayneNeed/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /Microsoft.DwayneNeed/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Microsoft.DwayneNeed.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.11.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Microsoft.DwayneNeed/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Microsoft.DwayneNeed/Themes/Generic.xaml: -------------------------------------------------------------------------------- 1 |  5 | 18 | 19 | -------------------------------------------------------------------------------- /README.markdown: -------------------------------------------------------------------------------- 1 |

WPF 4.0 Blend Mode Effect Library

2 | 3 |

This is a library of blend modes that can be used with WPF 4.0 (and forward).

4 | 5 |

I recently went through and compiled all the HLSL effect (.fx) files into pixel shader (.ps) files. This means that the library is now really a standalone library that you can just easily use in your WPF projects. I don't know why I haven't done this before!

6 | 7 |

I have a series of blog posts that describe these blend mode effects ... and which also details the journey in creating the library itself.

8 | 9 |

If you happen to use my library, I would love to hear about it. It was a labor of love!

10 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/EffectFiles/AverageEffect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | using System.Windows.Media.Effects; 5 | 6 | namespace BlendModeEffectLibrary 7 | { 8 | public class AverageEffect : BlendModeEffect 9 | { 10 | static AverageEffect() 11 | { 12 | _pixelShader.UriSource = Global.MakePackUri("ShaderSource/AverageEffect.ps"); 13 | } 14 | 15 | public AverageEffect() 16 | { 17 | this.PixelShader = _pixelShader; 18 | } 19 | 20 | private static PixelShader _pixelShader = new PixelShader(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/EffectFiles/BlendModeEffect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | using System.Windows.Media.Effects; 5 | 6 | namespace BlendModeEffectLibrary 7 | { 8 | public class BlendModeEffect : ShaderEffect 9 | { 10 | public BlendModeEffect() 11 | { 12 | UpdateShaderValue(AInputProperty); 13 | UpdateShaderValue(BInputProperty); 14 | } 15 | 16 | [System.ComponentModel.BrowsableAttribute(false)] 17 | public Brush AInput 18 | { 19 | get { return (Brush)GetValue(AInputProperty); } 20 | set { SetValue(AInputProperty, value); } 21 | } 22 | public static readonly DependencyProperty AInputProperty = 23 | ShaderEffect.RegisterPixelShaderSamplerProperty 24 | ( 25 | "AInput", 26 | typeof(BlendModeEffect), 27 | 0 28 | ); 29 | 30 | public Brush BInput 31 | { 32 | get { return (Brush)GetValue(BInputProperty); } 33 | set { SetValue(BInputProperty, value); } 34 | } 35 | public static readonly DependencyProperty BInputProperty = 36 | ShaderEffect.RegisterPixelShaderSamplerProperty 37 | ( 38 | "BInput", 39 | typeof(BlendModeEffect), 40 | 1 41 | ); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/EffectFiles/ColorBurnEffect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | using System.Windows.Media.Effects; 5 | 6 | namespace BlendModeEffectLibrary 7 | { 8 | public class ColorBurnEffect : BlendModeEffect 9 | { 10 | static ColorBurnEffect() 11 | { 12 | _pixelShader.UriSource = Global.MakePackUri("ShaderSource/ColorBurnEffect.ps"); 13 | } 14 | 15 | public ColorBurnEffect() 16 | { 17 | this.PixelShader = _pixelShader; 18 | } 19 | 20 | private static PixelShader _pixelShader = new PixelShader(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/EffectFiles/ColorDodgeEffect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | using System.Windows.Media.Effects; 5 | 6 | namespace BlendModeEffectLibrary 7 | { 8 | public class ColorDodgeEffect : BlendModeEffect 9 | { 10 | static ColorDodgeEffect() 11 | { 12 | _pixelShader.UriSource = Global.MakePackUri("ShaderSource/ColorDodgeEffect.ps"); 13 | } 14 | 15 | public ColorDodgeEffect() 16 | { 17 | this.PixelShader = _pixelShader; 18 | } 19 | 20 | private static PixelShader _pixelShader = new PixelShader(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/EffectFiles/ColorEffect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | using System.Windows.Media.Effects; 5 | 6 | namespace BlendModeEffectLibrary 7 | { 8 | public class ColorEffect : BlendModeEffect 9 | { 10 | static ColorEffect() 11 | { 12 | _pixelShader.UriSource = Global.MakePackUri("ShaderSource/ColorEffect.ps"); 13 | } 14 | 15 | public ColorEffect() 16 | { 17 | this.PixelShader = _pixelShader; 18 | } 19 | 20 | private static PixelShader _pixelShader = new PixelShader(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/EffectFiles/DarkenEffect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | using System.Windows.Media.Effects; 5 | 6 | namespace BlendModeEffectLibrary 7 | { 8 | public class DarkenEffect : BlendModeEffect 9 | { 10 | static DarkenEffect() 11 | { 12 | _pixelShader.UriSource = Global.MakePackUri("ShaderSource/DarkenEffect.ps"); 13 | } 14 | 15 | public DarkenEffect() 16 | { 17 | this.PixelShader = _pixelShader; 18 | } 19 | 20 | private static PixelShader _pixelShader = new PixelShader(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/EffectFiles/DifferenceEffect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | using System.Windows.Media.Effects; 5 | 6 | namespace BlendModeEffectLibrary 7 | { 8 | public class DifferenceEffect : BlendModeEffect 9 | { 10 | static DifferenceEffect() 11 | { 12 | _pixelShader.UriSource = Global.MakePackUri("ShaderSource/DifferenceEffect.ps"); 13 | } 14 | 15 | public DifferenceEffect() 16 | { 17 | this.PixelShader = _pixelShader; 18 | } 19 | 20 | private static PixelShader _pixelShader = new PixelShader(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/EffectFiles/ExclusionEffect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | using System.Windows.Media.Effects; 5 | 6 | namespace BlendModeEffectLibrary 7 | { 8 | public class ExclusionEffect : BlendModeEffect 9 | { 10 | static ExclusionEffect() 11 | { 12 | _pixelShader.UriSource = Global.MakePackUri("ShaderSource/ExclusionEffect.ps"); 13 | } 14 | 15 | public ExclusionEffect() 16 | { 17 | this.PixelShader = _pixelShader; 18 | } 19 | 20 | private static PixelShader _pixelShader = new PixelShader(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/EffectFiles/GlowEffect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | using System.Windows.Media.Effects; 5 | 6 | namespace BlendModeEffectLibrary 7 | { 8 | public class GlowEffect : BlendModeEffect 9 | { 10 | static GlowEffect() 11 | { 12 | _pixelShader.UriSource = Global.MakePackUri("ShaderSource/GlowEffect.ps"); 13 | } 14 | 15 | public GlowEffect() 16 | { 17 | this.PixelShader = _pixelShader; 18 | } 19 | 20 | private static PixelShader _pixelShader = new PixelShader(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/EffectFiles/HardLightEffect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | using System.Windows.Media.Effects; 5 | 6 | namespace BlendModeEffectLibrary 7 | { 8 | public class HardLightEffect : BlendModeEffect 9 | { 10 | static HardLightEffect() 11 | { 12 | _pixelShader.UriSource = Global.MakePackUri("ShaderSource/HardLightEffect.ps"); 13 | } 14 | 15 | public HardLightEffect() 16 | { 17 | this.PixelShader = _pixelShader; 18 | } 19 | 20 | private static PixelShader _pixelShader = new PixelShader(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/EffectFiles/HardMixEffect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | using System.Windows.Media.Effects; 5 | 6 | namespace BlendModeEffectLibrary 7 | { 8 | public class HardMixEffect : BlendModeEffect 9 | { 10 | static HardMixEffect() 11 | { 12 | _pixelShader.UriSource = Global.MakePackUri("ShaderSource/HardMixEffect.ps"); 13 | } 14 | 15 | public HardMixEffect() 16 | { 17 | this.PixelShader = _pixelShader; 18 | } 19 | 20 | private static PixelShader _pixelShader = new PixelShader(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/EffectFiles/HueEffect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | using System.Windows.Media.Effects; 5 | 6 | namespace BlendModeEffectLibrary 7 | { 8 | public class HueEffect : BlendModeEffect 9 | { 10 | static HueEffect() 11 | { 12 | _pixelShader.UriSource = Global.MakePackUri("ShaderSource/HueEffect.ps"); 13 | } 14 | 15 | public HueEffect() 16 | { 17 | this.PixelShader = _pixelShader; 18 | } 19 | 20 | private static PixelShader _pixelShader = new PixelShader(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/EffectFiles/LightenEffect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | using System.Windows.Media.Effects; 5 | 6 | namespace BlendModeEffectLibrary 7 | { 8 | public class LightenEffect : BlendModeEffect 9 | { 10 | static LightenEffect() 11 | { 12 | _pixelShader.UriSource = Global.MakePackUri("ShaderSource/LightenEffect.ps"); 13 | } 14 | 15 | public LightenEffect() 16 | { 17 | this.PixelShader = _pixelShader; 18 | } 19 | 20 | private static PixelShader _pixelShader = new PixelShader(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/EffectFiles/LinearBurnEffect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | using System.Windows.Media.Effects; 5 | 6 | namespace BlendModeEffectLibrary 7 | { 8 | public class LinearBurnEffect : BlendModeEffect 9 | { 10 | static LinearBurnEffect() 11 | { 12 | _pixelShader.UriSource = Global.MakePackUri("ShaderSource/LinearBurnEffect.ps"); 13 | } 14 | 15 | public LinearBurnEffect() 16 | { 17 | this.PixelShader = _pixelShader; 18 | } 19 | 20 | private static PixelShader _pixelShader = new PixelShader(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/EffectFiles/LinearDodgeEffect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | using System.Windows.Media.Effects; 5 | 6 | namespace BlendModeEffectLibrary 7 | { 8 | public class LinearDodgeEffect : BlendModeEffect 9 | { 10 | static LinearDodgeEffect() 11 | { 12 | _pixelShader.UriSource = Global.MakePackUri("ShaderSource/LinearDodgeEffect.ps"); 13 | } 14 | 15 | public LinearDodgeEffect() 16 | { 17 | this.PixelShader = _pixelShader; 18 | } 19 | 20 | private static PixelShader _pixelShader = new PixelShader(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/EffectFiles/LinearLightEffect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | using System.Windows.Media.Effects; 5 | 6 | namespace BlendModeEffectLibrary 7 | { 8 | public class LinearLightEffect : BlendModeEffect 9 | { 10 | static LinearLightEffect() 11 | { 12 | _pixelShader.UriSource = Global.MakePackUri("ShaderSource/LinearLightEffect.ps"); 13 | } 14 | 15 | public LinearLightEffect() 16 | { 17 | this.PixelShader = _pixelShader; 18 | } 19 | 20 | private static PixelShader _pixelShader = new PixelShader(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/EffectFiles/LuminosityEffect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | using System.Windows.Media.Effects; 5 | 6 | namespace BlendModeEffectLibrary 7 | { 8 | public class LuminosityEffect : BlendModeEffect 9 | { 10 | static LuminosityEffect() 11 | { 12 | _pixelShader.UriSource = Global.MakePackUri("ShaderSource/LuminosityEffect.ps"); 13 | } 14 | 15 | public LuminosityEffect() 16 | { 17 | this.PixelShader = _pixelShader; 18 | } 19 | 20 | private static PixelShader _pixelShader = new PixelShader(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/EffectFiles/MultiplyEffect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | using System.Windows.Media.Effects; 5 | 6 | namespace BlendModeEffectLibrary 7 | { 8 | public class MultiplyEffect : BlendModeEffect 9 | { 10 | static MultiplyEffect() 11 | { 12 | _pixelShader.UriSource = Global.MakePackUri("ShaderSource/MultiplyEffect.ps"); 13 | } 14 | 15 | public MultiplyEffect() 16 | { 17 | this.PixelShader = _pixelShader; 18 | } 19 | 20 | private static PixelShader _pixelShader = new PixelShader(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/EffectFiles/NegationEffect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | using System.Windows.Media.Effects; 5 | 6 | namespace BlendModeEffectLibrary 7 | { 8 | public class NegationEffect : BlendModeEffect 9 | { 10 | static NegationEffect() 11 | { 12 | _pixelShader.UriSource = Global.MakePackUri("ShaderSource/NegationEffect.ps"); 13 | } 14 | 15 | public NegationEffect() 16 | { 17 | this.PixelShader = _pixelShader; 18 | } 19 | 20 | private static PixelShader _pixelShader = new PixelShader(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/EffectFiles/NormalEffect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | using System.Windows.Media.Effects; 5 | 6 | namespace BlendModeEffectLibrary 7 | { 8 | public class NormalEffect : BlendModeEffect 9 | { 10 | static NormalEffect() 11 | { 12 | _pixelShader.UriSource = Global.MakePackUri("ShaderSource/NormalEffect.ps"); 13 | } 14 | 15 | public NormalEffect() 16 | { 17 | this.PixelShader = _pixelShader; 18 | } 19 | 20 | private static PixelShader _pixelShader = new PixelShader(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/EffectFiles/OverlayEffect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | using System.Windows.Media.Effects; 5 | 6 | namespace BlendModeEffectLibrary 7 | { 8 | public class OverlayEffect : BlendModeEffect 9 | { 10 | static OverlayEffect() 11 | { 12 | _pixelShader.UriSource = Global.MakePackUri("ShaderSource/OverlayEffect.ps"); 13 | } 14 | 15 | public OverlayEffect() 16 | { 17 | this.PixelShader = _pixelShader; 18 | } 19 | 20 | private static PixelShader _pixelShader = new PixelShader(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/EffectFiles/PhoenixEffect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | using System.Windows.Media.Effects; 5 | 6 | namespace BlendModeEffectLibrary 7 | { 8 | public class PhoenixEffect : BlendModeEffect 9 | { 10 | static PhoenixEffect() 11 | { 12 | _pixelShader.UriSource = Global.MakePackUri("ShaderSource/PhoenixEffect.ps"); 13 | } 14 | 15 | public PhoenixEffect() 16 | { 17 | this.PixelShader = _pixelShader; 18 | } 19 | 20 | private static PixelShader _pixelShader = new PixelShader(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/EffectFiles/PinLightEffect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | using System.Windows.Media.Effects; 5 | 6 | namespace BlendModeEffectLibrary 7 | { 8 | public class PinLightEffect : BlendModeEffect 9 | { 10 | static PinLightEffect() 11 | { 12 | _pixelShader.UriSource = Global.MakePackUri("ShaderSource/PinLightEffect.ps"); 13 | } 14 | 15 | public PinLightEffect() 16 | { 17 | this.PixelShader = _pixelShader; 18 | } 19 | 20 | private static PixelShader _pixelShader = new PixelShader(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/EffectFiles/ReflectEffect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | using System.Windows.Media.Effects; 5 | 6 | namespace BlendModeEffectLibrary 7 | { 8 | public class ReflectEffect : BlendModeEffect 9 | { 10 | static ReflectEffect() 11 | { 12 | _pixelShader.UriSource = Global.MakePackUri("ShaderSource/ReflectEffect.ps"); 13 | } 14 | 15 | public ReflectEffect() 16 | { 17 | this.PixelShader = _pixelShader; 18 | } 19 | 20 | private static PixelShader _pixelShader = new PixelShader(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/EffectFiles/SaturationEffect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | using System.Windows.Media.Effects; 5 | 6 | namespace BlendModeEffectLibrary 7 | { 8 | public class SaturationEffect : BlendModeEffect 9 | { 10 | static SaturationEffect() 11 | { 12 | _pixelShader.UriSource = Global.MakePackUri("ShaderSource/SaturationEffect.ps"); 13 | } 14 | 15 | public SaturationEffect() 16 | { 17 | this.PixelShader = _pixelShader; 18 | } 19 | 20 | private static PixelShader _pixelShader = new PixelShader(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/EffectFiles/ScreenEffect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | using System.Windows.Media.Effects; 5 | 6 | namespace BlendModeEffectLibrary 7 | { 8 | public class ScreenEffect : BlendModeEffect 9 | { 10 | static ScreenEffect() 11 | { 12 | _pixelShader.UriSource = Global.MakePackUri("ShaderSource/ScreenEffect.ps"); 13 | } 14 | 15 | public ScreenEffect() 16 | { 17 | this.PixelShader = _pixelShader; 18 | } 19 | 20 | private static PixelShader _pixelShader = new PixelShader(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/EffectFiles/SoftLightEffect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | using System.Windows.Media.Effects; 5 | 6 | namespace BlendModeEffectLibrary 7 | { 8 | public class SoftLightEffect : BlendModeEffect 9 | { 10 | static SoftLightEffect() 11 | { 12 | _pixelShader.UriSource = Global.MakePackUri("ShaderSource/SoftLightEffect.ps"); 13 | } 14 | 15 | public SoftLightEffect() 16 | { 17 | this.PixelShader = _pixelShader; 18 | } 19 | 20 | private static PixelShader _pixelShader = new PixelShader(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/EffectFiles/VividLightEffect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | using System.Windows.Media.Effects; 5 | 6 | namespace BlendModeEffectLibrary 7 | { 8 | public class VividLightEffect : BlendModeEffect 9 | { 10 | static VividLightEffect() 11 | { 12 | _pixelShader.UriSource = Global.MakePackUri("ShaderSource/VividLightEffect.ps"); 13 | } 14 | 15 | public VividLightEffect() 16 | { 17 | this.PixelShader = _pixelShader; 18 | } 19 | 20 | private static PixelShader _pixelShader = new PixelShader(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/EffectLibrary.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Reflection; 4 | using System.Text; 5 | 6 | namespace BlendModeEffectLibrary 7 | { 8 | internal static class Global 9 | { 10 | public static Uri MakePackUri(string relativeFile) 11 | { 12 | StringBuilder uriString = new StringBuilder(); 13 | #if !SILVERLIGHT 14 | uriString.Append("pack://application:,,,"); 15 | #endif 16 | uriString.Append("/" + AssemblyShortName + ";component/" + relativeFile); 17 | return new Uri(uriString.ToString(), UriKind.RelativeOrAbsolute); 18 | } 19 | 20 | private static string AssemblyShortName 21 | { 22 | get 23 | { 24 | if (_assemblyShortName == null) 25 | { 26 | Assembly a = typeof(Global).Assembly; 27 | 28 | // Pull out the short name. 29 | _assemblyShortName = a.ToString().Split(',')[0]; 30 | } 31 | 32 | return _assemblyShortName; 33 | } 34 | } 35 | 36 | private static string _assemblyShortName; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("MyEffects")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("MyEffects")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2009")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("8aee1ced-bda5-4012-a753-65ecf4fbbd63")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/AverageEffect.fx: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------- 2 | // 3 | // WPF ShaderEffect HLSL -- AverageEffect 4 | // 5 | //-------------------------------------------------------------------------------------- 6 | 7 | sampler2D input : register(s0); 8 | sampler2D blend : register(s1); 9 | 10 | float4 main(float2 uv : TEXCOORD) : COLOR 11 | { 12 | float4 inputColor; 13 | inputColor = tex2D(input, uv); 14 | 15 | float4 blendColor; 16 | blendColor = tex2D(blend, uv); 17 | 18 | 19 | float4 resultColor; 20 | resultColor.a = inputColor.a; 21 | 22 | // un-premultiply the blendColor alpha out from blendColor 23 | blendColor.rgb = clamp(blendColor.rgb / blendColor.a, 0, 1); 24 | 25 | 26 | // apply the blend mode math 27 | resultColor.rgb = (inputColor.rgb + blendColor.rgb) / 2; 28 | 29 | 30 | // re-multiply the blendColor alpha in to blendColor, weight inputColor according to blendColor.a 31 | resultColor.rgb = (1 - blendColor.a) * inputColor.rgb + resultColor.rgb * blendColor.a; 32 | 33 | return resultColor; 34 | } 35 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/AverageEffect.ps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/WPFBlendModeEffectLibrary/ShaderSource/AverageEffect.ps -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/ColorBurnEffect.fx: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------- 2 | // 3 | // WPF ShaderEffect HLSL -- ColorBurnEffect 4 | // 5 | //-------------------------------------------------------------------------------------- 6 | 7 | sampler2D input : register(s0); 8 | sampler2D blend : register(s1); 9 | 10 | //-------------------------------------------------------------------------------------- 11 | // Pixel Shader 12 | //-------------------------------------------------------------------------------------- 13 | 14 | float4 main(float2 uv : TEXCOORD) : COLOR 15 | { 16 | float4 inputColor; 17 | inputColor = tex2D(input, uv); 18 | 19 | float4 blendColor; 20 | blendColor = tex2D(blend, uv); 21 | 22 | 23 | float4 resultColor; 24 | resultColor.a = inputColor.a; 25 | 26 | // un-premultiply the blendColor alpha out from blendColor 27 | blendColor.rgb = clamp(blendColor.rgb / blendColor.a, 0, 1); 28 | 29 | 30 | // apply the blend mode math 31 | // R = 1 - (1-Base) / Blend 32 | resultColor.rgb = clamp(1 - (1 - inputColor.rgb) / blendColor.rgb, 0, 1); 33 | 34 | 35 | // re-multiply the blendColor alpha in to blendColor, weight inputColor according to blendColor.a 36 | resultColor.rgb = (1 - blendColor.a) * inputColor.rgb + resultColor.rgb * blendColor.a; 37 | 38 | return resultColor; 39 | } 40 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/ColorBurnEffect.ps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/WPFBlendModeEffectLibrary/ShaderSource/ColorBurnEffect.ps -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/ColorDodgeEffect.fx: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------- 2 | // 3 | // WPF ShaderEffect HLSL -- ColorDodgeEffect 4 | // 5 | //-------------------------------------------------------------------------------------- 6 | 7 | #define BlendColorDodgef(base, blend) ((blend == 1.0) ? blend : min(base / (1.0 - blend), 1.0)) 8 | 9 | sampler2D input : register(s0); 10 | sampler2D blend : register(s1); 11 | 12 | //-------------------------------------------------------------------------------------- 13 | // Pixel Shader 14 | //-------------------------------------------------------------------------------------- 15 | 16 | float4 main(float2 uv : TEXCOORD) : COLOR 17 | { 18 | float4 inputColor; 19 | inputColor = tex2D(input, uv); 20 | 21 | float4 blendColor; 22 | blendColor = tex2D(blend, uv); 23 | 24 | 25 | float4 resultColor; 26 | resultColor.a = inputColor.a; 27 | 28 | // un-premultiply the blendColor alpha out from blendColor 29 | blendColor.rgb = clamp(blendColor.rgb / blendColor.a, 0, 1); 30 | 31 | 32 | // apply the blend mode math 33 | // R = Base / (1-Blend) 34 | resultColor.r = BlendColorDodgef(inputColor.r, blendColor.r); 35 | resultColor.g = BlendColorDodgef(inputColor.g, blendColor.g); 36 | resultColor.b = BlendColorDodgef(inputColor.b, blendColor.b); 37 | 38 | 39 | // re-multiply the blendColor alpha in to blendColor, weight inputColor according to blendColor.a 40 | resultColor.rgb = (1 - blendColor.a) * inputColor.rgb + resultColor.rgb * blendColor.a; 41 | 42 | return resultColor; 43 | } 44 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/ColorDodgeEffect.ps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/WPFBlendModeEffectLibrary/ShaderSource/ColorDodgeEffect.ps -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/ColorEffect.fx: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------- 2 | // 3 | // WPF ShaderEffect HLSL -- ColorEffect 4 | // 5 | // Color blend mode keeps the brightness of the base color and applies both the hue and 6 | // saturation of the blend color. 7 | // 8 | //-------------------------------------------------------------------------------------- 9 | 10 | sampler2D input : register(s0); 11 | sampler2D blend : register(s1); 12 | 13 | //-------------------------------------------------------------------------------------- 14 | // Pixel Shader 15 | //-------------------------------------------------------------------------------------- 16 | 17 | float3 RGBToHSL(float3 color) 18 | { 19 | float3 hsl; 20 | 21 | float fmin = min(min(color.r, color.g), color.b); 22 | float fmax = max(max(color.r, color.g), color.b); 23 | float delta = fmax - fmin; 24 | float maxplusmin = fmax + fmin; 25 | 26 | // set luminance 27 | hsl.z = maxplusmin / 2.0; 28 | 29 | if (delta == 0.0) 30 | { 31 | // a gray color, set hue and satuation to 0 32 | hsl.x = 0.0; 33 | hsl.y = 0.0; 34 | } 35 | else 36 | { 37 | // not a gray color 38 | 39 | // set saturation 40 | if (hsl.z < 0.5) 41 | hsl.y = delta / (maxplusmin); 42 | else 43 | hsl.y = delta / (2.0 - maxplusmin); 44 | 45 | if (color.r == fmax) 46 | hsl.x = ((color.g - color.b) / delta); 47 | else if (color.g == fmax) 48 | hsl.x = 2.0 + ((color.b - color.r) / delta); 49 | else if (color.b == fmax) 50 | hsl.x = 4.0 + ((color.r - color.g) / delta); 51 | 52 | hsl.x = hsl.x / 6.0; 53 | 54 | if (hsl.x < 0.0) 55 | hsl.x += 1.0; 56 | } 57 | 58 | return hsl; 59 | } 60 | 61 | float HueToRGB(float temp1, float temp2, float temp3) 62 | { 63 | if (temp3 < 0.0) 64 | temp3 += 1.0; 65 | else if (temp3 > 1.0) 66 | temp3 -= 1.0; 67 | 68 | float rgbComponent; 69 | 70 | if ((6.0 * temp3) < 1.0) 71 | rgbComponent = temp1 + (temp2 - temp1) * 6.0 * temp3; 72 | else if ((2.0 * temp3) < 1.0) 73 | rgbComponent = temp2; 74 | else if ((3.0 * temp3) < 2.0) 75 | rgbComponent = temp1 + (temp2 - temp1) * ((2.0 / 3.0) - temp3) * 6.0; 76 | else 77 | rgbComponent = temp1; 78 | 79 | return rgbComponent; 80 | } 81 | 82 | float3 HSLToRGB(float3 hsl) 83 | { 84 | float3 rgb; 85 | 86 | if (hsl.y == 0.0) 87 | { 88 | rgb = float3(hsl.z, hsl.z, hsl.z); 89 | } 90 | else 91 | { 92 | float temp2; 93 | if (hsl.z < 0.5) 94 | temp2 = hsl.z * (1.0 + hsl.y); 95 | else 96 | temp2 = (hsl.y + hsl.z) - (hsl.y * hsl.z); 97 | 98 | float temp1 = 2.0 * hsl.z - temp2; 99 | 100 | rgb.r = HueToRGB(temp1, temp2, hsl.x + (1.0/3.0)); 101 | rgb.g = HueToRGB(temp1, temp2, hsl.x); 102 | rgb.b = HueToRGB(temp1, temp2, hsl.x - (1.0/3.0)); 103 | } 104 | 105 | return rgb; 106 | } 107 | 108 | float3 BlendColor(float3 base, float3 blend) 109 | { 110 | float3 blendHSL = RGBToHSL(blend); 111 | return HSLToRGB(float3(blendHSL.r, blendHSL.g, RGBToHSL(base).b)); 112 | } 113 | 114 | float4 main(float2 uv : TEXCOORD) : COLOR 115 | { 116 | float4 inputColor; 117 | inputColor = tex2D(input, uv); 118 | 119 | float4 blendColor; 120 | blendColor = tex2D(blend, uv); 121 | 122 | 123 | float4 resultColor; 124 | resultColor.a = inputColor.a; 125 | 126 | // un-premultiply the blendColor alpha out from blendColor 127 | blendColor.rgb = clamp(blendColor.rgb / blendColor.a, 0, 1); 128 | 129 | 130 | // apply the blend mode math 131 | resultColor.rgb = BlendColor(inputColor.rgb, blendColor.rgb); 132 | 133 | 134 | // re-multiply the blendColor alpha in to blendColor, weight inputColor according to blendColor.a 135 | resultColor.rgb = (1 - blendColor.a) * inputColor.rgb + resultColor.rgb * blendColor.a; 136 | 137 | return resultColor; 138 | } 139 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/ColorEffect.ps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/WPFBlendModeEffectLibrary/ShaderSource/ColorEffect.ps -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/DarkenEffect.fx: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------- 2 | // 3 | // WPF ShaderEffect HLSL -- DarkenEffect 4 | // 5 | //-------------------------------------------------------------------------------------- 6 | 7 | sampler2D input : register(s0); 8 | sampler2D blend : register(s1); 9 | 10 | float4 main(float2 uv : TEXCOORD) : COLOR 11 | { 12 | float4 inputColor; 13 | inputColor = tex2D(input, uv); 14 | 15 | float4 blendColor; 16 | blendColor = tex2D(blend, uv); 17 | 18 | 19 | float4 resultColor; 20 | resultColor.a = inputColor.a; 21 | 22 | // un-premultiply the blendColor alpha out from blendColor 23 | blendColor.rgb = clamp(blendColor.rgb / blendColor.a, 0, 1); 24 | 25 | 26 | // apply the blend mode math 27 | if (inputColor.r > blendColor.r) 28 | resultColor.r = blendColor.r; 29 | else 30 | resultColor.r = inputColor.r; 31 | 32 | if (inputColor.g > blendColor.g) 33 | resultColor.g = blendColor.g; 34 | else 35 | resultColor.g = inputColor.g; 36 | 37 | if (inputColor.b > blendColor.b) 38 | resultColor.b = blendColor.b; 39 | else 40 | resultColor.b = inputColor.b; 41 | 42 | 43 | // re-multiply the blendColor alpha in to blendColor, weight inputColor according to blendColor.a 44 | resultColor.rgb = (1 - blendColor.a) * inputColor.rgb + resultColor.rgb * blendColor.a; 45 | 46 | return resultColor; 47 | } 48 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/DarkenEffect.ps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/WPFBlendModeEffectLibrary/ShaderSource/DarkenEffect.ps -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/DifferenceEffect.fx: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------- 2 | // 3 | // WPF ShaderEffect HLSL -- DifferenceEffect 4 | // 5 | //-------------------------------------------------------------------------------------- 6 | 7 | sampler2D input : register(s0); 8 | sampler2D blend : register(s1); 9 | 10 | float4 main(float2 uv : TEXCOORD) : COLOR 11 | { 12 | float4 inputColor; 13 | inputColor = tex2D(input, uv); 14 | 15 | float4 blendColor; 16 | blendColor = tex2D(blend, uv); 17 | 18 | 19 | float4 resultColor; 20 | resultColor.a = inputColor.a; 21 | 22 | // un-premultiply the blendColor alpha out from blendColor 23 | blendColor.rgb = clamp(blendColor.rgb / blendColor.a, 0, 1); 24 | 25 | 26 | // apply the blend mode math 27 | // R = | Base - Blend | 28 | resultColor.rgb = abs(inputColor.rgb - blendColor.rgb); 29 | 30 | 31 | // re-multiply the blendColor alpha in to blendColor, weight inputColor according to blendColor.a 32 | resultColor.rgb = (1 - blendColor.a) * inputColor.rgb + resultColor.rgb * blendColor.a; 33 | 34 | return resultColor; 35 | } 36 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/DifferenceEffect.ps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/WPFBlendModeEffectLibrary/ShaderSource/DifferenceEffect.ps -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/ExclusionEffect.fx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/WPFBlendModeEffectLibrary/ShaderSource/ExclusionEffect.fx -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/ExclusionEffect.ps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/WPFBlendModeEffectLibrary/ShaderSource/ExclusionEffect.ps -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/GlowEffect.fx: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------- 2 | // 3 | // WPF ShaderEffect HLSL -- GlowEffect 4 | // 5 | //-------------------------------------------------------------------------------------- 6 | 7 | #define BlendReflectf(base, blend) ((blend == 1.0) ? blend : min(base * base / (1.0 - blend), 1.0)) 8 | 9 | sampler2D input : register(s0); 10 | sampler2D blend : register(s1); 11 | 12 | //-------------------------------------------------------------------------------------- 13 | // Pixel Shader 14 | //-------------------------------------------------------------------------------------- 15 | 16 | float4 main(float2 uv : TEXCOORD) : COLOR 17 | { 18 | float4 inputColor; 19 | inputColor = tex2D(input, uv); 20 | 21 | float4 blendColor; 22 | blendColor = tex2D(blend, uv); 23 | 24 | 25 | float4 resultColor; 26 | resultColor.a = inputColor.a; 27 | 28 | // un-premultiply the blendColor alpha out from blendColor 29 | blendColor.rgb = clamp(blendColor.rgb / blendColor.a, 0, 1); 30 | 31 | 32 | // apply the blend mode math 33 | resultColor.r = BlendReflectf(blendColor.r, inputColor.r); 34 | resultColor.g = BlendReflectf(blendColor.g, inputColor.g); 35 | resultColor.b = BlendReflectf(blendColor.b, inputColor.b); 36 | 37 | 38 | // re-multiply the blendColor alpha in to blendColor, weight inputColor according to blendColor.a 39 | resultColor.rgb = (1 - blendColor.a) * inputColor.rgb + resultColor.rgb * blendColor.a; 40 | 41 | return resultColor; 42 | } 43 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/GlowEffect.ps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/WPFBlendModeEffectLibrary/ShaderSource/GlowEffect.ps -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/HardLightEffect.fx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/WPFBlendModeEffectLibrary/ShaderSource/HardLightEffect.fx -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/HardLightEffect.ps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/WPFBlendModeEffectLibrary/ShaderSource/HardLightEffect.ps -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/HardMixEffect.fx: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------- 2 | // 3 | // WPF ShaderEffect HLSL -- HardMixEffect 4 | // 5 | //-------------------------------------------------------------------------------------- 6 | 7 | #define BlendColorDodgef(base, blend) ((blend == 1.0) ? blend : min(base / (1.0 - blend), 1.0)) 8 | #define BlendColorBurnf(base, blend) ((blend == 0.0) ? blend : max((1.0 - ((1.0 - base) / blend)), 0.0)) 9 | #define BlendVividLightf(base, blend) ((blend < 0.5) ? BlendColorBurnf(base, (2.0 * blend)) : BlendColorDodgef(base, (2.0 * (blend - 0.5)))) 10 | #define BlendHardMixf(base, blend) ((BlendVividLightf(base, blend) < 0.5) ? 0.0 : 1.0) 11 | 12 | sampler2D input : register(s0); 13 | sampler2D blend : register(s1); 14 | 15 | //-------------------------------------------------------------------------------------- 16 | // Pixel Shader 17 | //-------------------------------------------------------------------------------------- 18 | 19 | float4 main(float2 uv : TEXCOORD) : COLOR 20 | { 21 | float4 inputColor; 22 | inputColor = tex2D(input, uv); 23 | 24 | float4 blendColor; 25 | blendColor = tex2D(blend, uv); 26 | 27 | 28 | float4 resultColor; 29 | resultColor.a = inputColor.a; 30 | 31 | // un-premultiply the blendColor alpha out from blendColor 32 | blendColor.rgb = clamp(blendColor.rgb / blendColor.a, 0, 1); 33 | 34 | 35 | // apply the blend mode math 36 | resultColor.r = BlendHardMixf(inputColor.r, blendColor.r); 37 | resultColor.g = BlendHardMixf(inputColor.g, blendColor.g); 38 | resultColor.b = BlendHardMixf(inputColor.b, blendColor.b); 39 | 40 | 41 | // re-multiply the blendColor alpha in to blendColor, weight inputColor according to blendColor.a 42 | resultColor.rgb = (1 - blendColor.a) * inputColor.rgb + resultColor.rgb * blendColor.a; 43 | 44 | return resultColor; 45 | } 46 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/HardMixEffect.ps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/WPFBlendModeEffectLibrary/ShaderSource/HardMixEffect.ps -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/HueEffect.fx: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------- 2 | // 3 | // WPF ShaderEffect HLSL -- HueEffect 4 | // 5 | // Hue blend mode creates the result color by combining the luminance and saturation of 6 | // the base color with the hue of the blend color. 7 | // 8 | //-------------------------------------------------------------------------------------- 9 | 10 | sampler2D input : register(s0); 11 | sampler2D blend : register(s1); 12 | 13 | //-------------------------------------------------------------------------------------- 14 | // Pixel Shader 15 | //-------------------------------------------------------------------------------------- 16 | 17 | float3 RGBToHSL(float3 color) 18 | { 19 | float3 hsl; 20 | 21 | float fmin = min(min(color.r, color.g), color.b); 22 | float fmax = max(max(color.r, color.g), color.b); 23 | float delta = fmax - fmin; 24 | float maxplusmin = fmax + fmin; 25 | 26 | // set luminance 27 | hsl.z = maxplusmin / 2.0; 28 | 29 | if (delta == 0.0) 30 | { 31 | // a gray color, set hue and satuation to 0 32 | hsl.x = 0.0; 33 | hsl.y = 0.0; 34 | } 35 | else 36 | { 37 | // not a gray color 38 | 39 | // set saturation 40 | if (hsl.z < 0.5) 41 | hsl.y = delta / (maxplusmin); 42 | else 43 | hsl.y = delta / (2.0 - maxplusmin); 44 | 45 | if (color.r == fmax) 46 | hsl.x = ((color.g - color.b) / delta); 47 | else if (color.g == fmax) 48 | hsl.x = 2.0 + ((color.b - color.r) / delta); 49 | else if (color.b == fmax) 50 | hsl.x = 4.0 + ((color.r - color.g) / delta); 51 | 52 | hsl.x = hsl.x / 6.0; 53 | 54 | if (hsl.x < 0.0) 55 | hsl.x += 1.0; 56 | } 57 | 58 | return hsl; 59 | } 60 | 61 | float HueToRGB(float temp1, float temp2, float temp3) 62 | { 63 | if (temp3 < 0.0) 64 | temp3 += 1.0; 65 | else if (temp3 > 1.0) 66 | temp3 -= 1.0; 67 | 68 | float rgbComponent; 69 | 70 | if ((6.0 * temp3) < 1.0) 71 | rgbComponent = temp1 + (temp2 - temp1) * 6.0 * temp3; 72 | else if ((2.0 * temp3) < 1.0) 73 | rgbComponent = temp2; 74 | else if ((3.0 * temp3) < 2.0) 75 | rgbComponent = temp1 + (temp2 - temp1) * ((2.0 / 3.0) - temp3) * 6.0; 76 | else 77 | rgbComponent = temp1; 78 | 79 | return rgbComponent; 80 | } 81 | 82 | float3 HSLToRGB(float3 hsl) 83 | { 84 | float3 rgb; 85 | 86 | if (hsl.y == 0.0) 87 | { 88 | rgb = float3(hsl.z, hsl.z, hsl.z); 89 | } 90 | else 91 | { 92 | float temp2; 93 | if (hsl.z < 0.5) 94 | temp2 = hsl.z * (1.0 + hsl.y); 95 | else 96 | temp2 = (hsl.y + hsl.z) - (hsl.y * hsl.z); 97 | 98 | float temp1 = 2.0 * hsl.z - temp2; 99 | 100 | rgb.r = HueToRGB(temp1, temp2, hsl.x + (1.0/3.0)); 101 | rgb.g = HueToRGB(temp1, temp2, hsl.x); 102 | rgb.b = HueToRGB(temp1, temp2, hsl.x - (1.0/3.0)); 103 | } 104 | 105 | return rgb; 106 | } 107 | 108 | float3 BlendHue(float3 base, float3 blend) 109 | { 110 | float3 baseHSL = RGBToHSL(base); 111 | return HSLToRGB(float3(RGBToHSL(blend).x, baseHSL.y, baseHSL.z)); 112 | } 113 | 114 | float4 main(float2 uv : TEXCOORD) : COLOR 115 | { 116 | float4 inputColor; 117 | inputColor = tex2D(input, uv); 118 | 119 | float4 blendColor; 120 | blendColor = tex2D(blend, uv); 121 | 122 | 123 | float4 resultColor; 124 | resultColor.a = inputColor.a; 125 | 126 | // un-premultiply the blendColor alpha out from blendColor 127 | blendColor.rgb = clamp(blendColor.rgb / blendColor.a, 0, 1); 128 | 129 | 130 | // apply the blend mode math 131 | resultColor.rgb = BlendHue(inputColor.rgb, blendColor.rgb); 132 | 133 | 134 | // re-multiply the blendColor alpha in to blendColor, weight inputColor according to blendColor.a 135 | resultColor.rgb = (1 - blendColor.a) * inputColor.rgb + resultColor.rgb * blendColor.a; 136 | 137 | return resultColor; 138 | } 139 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/HueEffect.ps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/WPFBlendModeEffectLibrary/ShaderSource/HueEffect.ps -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/LightenEffect.fx: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------- 2 | // 3 | // WPF ShaderEffect HLSL -- LightenEffect 4 | // 5 | //-------------------------------------------------------------------------------------- 6 | 7 | sampler2D input : register(s0); 8 | sampler2D blend : register(s1); 9 | 10 | float4 main(float2 uv : TEXCOORD) : COLOR 11 | { 12 | float4 inputColor; 13 | inputColor = tex2D(input, uv); 14 | 15 | float4 blendColor; 16 | blendColor = tex2D(blend, uv); 17 | 18 | 19 | float4 resultColor; 20 | resultColor.a = inputColor.a; 21 | 22 | // un-premultiply the blendColor alpha out from blendColor 23 | blendColor.rgb = clamp(blendColor.rgb / blendColor.a, 0, 1); 24 | 25 | 26 | // apply the blend mode math 27 | if (inputColor.r < blendColor.r) 28 | resultColor.r = blendColor.r; 29 | else 30 | resultColor.r = inputColor.r; 31 | 32 | if (inputColor.g < blendColor.g) 33 | resultColor.g = blendColor.g; 34 | else 35 | resultColor.g = inputColor.g; 36 | 37 | if (inputColor.b < blendColor.b) 38 | resultColor.b = blendColor.b; 39 | else 40 | resultColor.b = inputColor.b; 41 | 42 | 43 | // re-multiply the blendColor alpha in to blendColor, weight inputColor according to blendColor.a 44 | resultColor.rgb = (1 - blendColor.a) * inputColor.rgb + resultColor.rgb * blendColor.a; 45 | 46 | return resultColor; 47 | } 48 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/LightenEffect.ps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/WPFBlendModeEffectLibrary/ShaderSource/LightenEffect.ps -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/LinearBurnEffect.fx: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------- 2 | // 3 | // WPF ShaderEffect HLSL -- LinearBurnEffect 4 | // 5 | //-------------------------------------------------------------------------------------- 6 | 7 | sampler2D input : register(s0); 8 | sampler2D blend : register(s1); 9 | 10 | //-------------------------------------------------------------------------------------- 11 | // Pixel Shader 12 | //-------------------------------------------------------------------------------------- 13 | 14 | float4 main(float2 uv : TEXCOORD) : COLOR 15 | { 16 | float4 inputColor; 17 | inputColor = tex2D(input, uv); 18 | 19 | float4 blendColor; 20 | blendColor = tex2D(blend, uv); 21 | 22 | 23 | float4 resultColor; 24 | resultColor.a = inputColor.a; 25 | 26 | // un-premultiply the blendColor alpha out from blendColor 27 | blendColor.rgb = clamp(blendColor.rgb / blendColor.a, 0, 1); 28 | 29 | 30 | // apply the blend mode math 31 | // R = Base + Blend - 1 32 | resultColor.rgb = clamp(inputColor.rgb + blendColor.rgb - 1, 0, 1); 33 | 34 | 35 | // re-multiply the blendColor alpha in to blendColor, weight inputColor according to blendColor.a 36 | resultColor.rgb = (1 - blendColor.a) * inputColor.rgb + resultColor.rgb * blendColor.a; 37 | 38 | return resultColor; 39 | } 40 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/LinearBurnEffect.ps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/WPFBlendModeEffectLibrary/ShaderSource/LinearBurnEffect.ps -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/LinearDodgeEffect.fx: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------- 2 | // 3 | // WPF ShaderEffect HLSL -- LinearDodgeEffect 4 | // 5 | //-------------------------------------------------------------------------------------- 6 | 7 | sampler2D input : register(s0); 8 | sampler2D blend : register(s1); 9 | 10 | //-------------------------------------------------------------------------------------- 11 | // Pixel Shader 12 | //-------------------------------------------------------------------------------------- 13 | 14 | float4 main(float2 uv : TEXCOORD) : COLOR 15 | { 16 | float4 inputColor; 17 | inputColor = tex2D(input, uv); 18 | 19 | float4 blendColor; 20 | blendColor = tex2D(blend, uv); 21 | 22 | 23 | float4 resultColor; 24 | resultColor.a = inputColor.a; 25 | 26 | // un-premultiply the blendColor alpha out from blendColor 27 | blendColor.rgb = clamp(blendColor.rgb / blendColor.a, 0, 1); 28 | 29 | 30 | // apply the blend mode math 31 | // R = Base + Blend 32 | resultColor.rgb = inputColor.rgb + blendColor.rgb; 33 | 34 | 35 | // re-multiply the blendColor alpha in to blendColor, weight inputColor according to blendColor.a 36 | resultColor.rgb = (1 - blendColor.a) * inputColor.rgb + resultColor.rgb * blendColor.a; 37 | 38 | return resultColor; 39 | } 40 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/LinearDodgeEffect.ps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/WPFBlendModeEffectLibrary/ShaderSource/LinearDodgeEffect.ps -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/LinearLightEffect.fx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/WPFBlendModeEffectLibrary/ShaderSource/LinearLightEffect.fx -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/LinearLightEffect.ps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/WPFBlendModeEffectLibrary/ShaderSource/LinearLightEffect.ps -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/LuminosityEffect.fx: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------- 2 | // 3 | // WPF ShaderEffect HLSL -- LuminosityEffect 4 | // 5 | // Luminosity blend mode creates the result color by combining the hue and saturation 6 | // of the base color with the luminance of the blend color. 7 | // 8 | //-------------------------------------------------------------------------------------- 9 | 10 | sampler2D input : register(s0); 11 | sampler2D blend : register(s1); 12 | 13 | //-------------------------------------------------------------------------------------- 14 | // Pixel Shader 15 | //-------------------------------------------------------------------------------------- 16 | 17 | float3 RGBToHSL(float3 color) 18 | { 19 | float3 hsl; 20 | 21 | float fmin = min(min(color.r, color.g), color.b); 22 | float fmax = max(max(color.r, color.g), color.b); 23 | float delta = fmax - fmin; 24 | float maxplusmin = fmax + fmin; 25 | 26 | // set luminance 27 | hsl.z = maxplusmin / 2.0; 28 | 29 | if (delta == 0.0) 30 | { 31 | // a gray color, set hue and satuation to 0 32 | hsl.x = 0.0; 33 | hsl.y = 0.0; 34 | } 35 | else 36 | { 37 | // not a gray color 38 | 39 | // set saturation 40 | if (hsl.z < 0.5) 41 | hsl.y = delta / (maxplusmin); 42 | else 43 | hsl.y = delta / (2.0 - maxplusmin); 44 | 45 | if (color.r == fmax) 46 | hsl.x = ((color.g - color.b) / delta); 47 | else if (color.g == fmax) 48 | hsl.x = 2.0 + ((color.b - color.r) / delta); 49 | else if (color.b == fmax) 50 | hsl.x = 4.0 + ((color.r - color.g) / delta); 51 | 52 | hsl.x = hsl.x / 6.0; 53 | 54 | if (hsl.x < 0.0) 55 | hsl.x += 1.0; 56 | } 57 | 58 | return hsl; 59 | } 60 | 61 | float HueToRGB(float temp1, float temp2, float temp3) 62 | { 63 | if (temp3 < 0.0) 64 | temp3 += 1.0; 65 | else if (temp3 > 1.0) 66 | temp3 -= 1.0; 67 | 68 | float rgbComponent; 69 | 70 | if ((6.0 * temp3) < 1.0) 71 | rgbComponent = temp1 + (temp2 - temp1) * 6.0 * temp3; 72 | else if ((2.0 * temp3) < 1.0) 73 | rgbComponent = temp2; 74 | else if ((3.0 * temp3) < 2.0) 75 | rgbComponent = temp1 + (temp2 - temp1) * ((2.0 / 3.0) - temp3) * 6.0; 76 | else 77 | rgbComponent = temp1; 78 | 79 | return rgbComponent; 80 | } 81 | 82 | float3 HSLToRGB(float3 hsl) 83 | { 84 | float3 rgb; 85 | 86 | if (hsl.y == 0.0) 87 | { 88 | rgb = float3(hsl.z, hsl.z, hsl.z); 89 | } 90 | else 91 | { 92 | float temp2; 93 | if (hsl.z < 0.5) 94 | temp2 = hsl.z * (1.0 + hsl.y); 95 | else 96 | temp2 = (hsl.y + hsl.z) - (hsl.y * hsl.z); 97 | 98 | float temp1 = 2.0 * hsl.z - temp2; 99 | 100 | rgb.r = HueToRGB(temp1, temp2, hsl.x + (1.0/3.0)); 101 | rgb.g = HueToRGB(temp1, temp2, hsl.x); 102 | rgb.b = HueToRGB(temp1, temp2, hsl.x - (1.0/3.0)); 103 | } 104 | 105 | return rgb; 106 | } 107 | 108 | float3 BlendLuminosity(float3 base, float3 blend) 109 | { 110 | float3 baseHSL = RGBToHSL(base); 111 | return HSLToRGB(float3(baseHSL.x, baseHSL.y, RGBToHSL(blend).z)); 112 | } 113 | 114 | float4 main(float2 uv : TEXCOORD) : COLOR 115 | { 116 | float4 inputColor; 117 | inputColor = tex2D(input, uv); 118 | 119 | float4 blendColor; 120 | blendColor = tex2D(blend, uv); 121 | 122 | 123 | float4 resultColor; 124 | resultColor.a = inputColor.a; 125 | 126 | // un-premultiply the blendColor alpha out from blendColor 127 | blendColor.rgb = clamp(blendColor.rgb / blendColor.a, 0, 1); 128 | 129 | 130 | // apply the blend mode math 131 | resultColor.rgb = BlendLuminosity(inputColor.rgb, blendColor.rgb); 132 | 133 | 134 | // re-multiply the blendColor alpha in to blendColor, weight inputColor according to blendColor.a 135 | resultColor.rgb = (1 - blendColor.a) * inputColor.rgb + resultColor.rgb * blendColor.a; 136 | 137 | return resultColor; 138 | } 139 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/LuminosityEffect.ps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/WPFBlendModeEffectLibrary/ShaderSource/LuminosityEffect.ps -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/MultiplyEffect.fx: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------- 2 | // 3 | // WPF ShaderEffect HLSL -- MultiplyEffect 4 | // 5 | //-------------------------------------------------------------------------------------- 6 | 7 | sampler2D input : register(s0); 8 | sampler2D blend : register(s1); 9 | 10 | float4 main(float2 uv : TEXCOORD) : COLOR 11 | { 12 | float4 inputColor; 13 | inputColor = tex2D(input, uv); 14 | 15 | float4 blendColor; 16 | blendColor = tex2D(blend, uv); 17 | 18 | 19 | float4 resultColor; 20 | resultColor.a = inputColor.a; 21 | 22 | // un-premultiply the blendColor alpha out from blendColor 23 | blendColor.rgb = clamp(blendColor.rgb / blendColor.a, 0, 1); 24 | 25 | 26 | // apply the blend mode math 27 | // R = Base * Blend 28 | resultColor.rgb = blendColor.rgb * inputColor.rgb; 29 | 30 | 31 | // re-multiply the blendColor alpha in to blendColor, weight inputColor according to blendColor.a 32 | resultColor.rgb = (1 - blendColor.a) * inputColor.rgb + resultColor.rgb * blendColor.a; 33 | 34 | return resultColor; 35 | } 36 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/MultiplyEffect.ps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/WPFBlendModeEffectLibrary/ShaderSource/MultiplyEffect.ps -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/NegationEffect.fx: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------- 2 | // 3 | // WPF ShaderEffect HLSL -- NegationEffect 4 | // 5 | //-------------------------------------------------------------------------------------- 6 | 7 | #define BlendNegation(base, blend) (float3(1.0, 1.0, 1.0) - abs(float3(1.0, 1.0, 1.0) - base - blend)) 8 | 9 | sampler2D input : register(s0); 10 | sampler2D blend : register(s1); 11 | 12 | //-------------------------------------------------------------------------------------- 13 | // Pixel Shader 14 | //-------------------------------------------------------------------------------------- 15 | 16 | float4 main(float2 uv : TEXCOORD) : COLOR 17 | { 18 | float4 inputColor; 19 | inputColor = tex2D(input, uv); 20 | 21 | float4 blendColor; 22 | blendColor = tex2D(blend, uv); 23 | 24 | 25 | float4 resultColor; 26 | resultColor.a = inputColor.a; 27 | 28 | // un-premultiply the blendColor alpha out from blendColor 29 | blendColor.rgb = clamp(blendColor.rgb / blendColor.a, 0, 1); 30 | 31 | 32 | // apply the blend mode math 33 | resultColor.rgb = BlendNegation(inputColor, blendColor); 34 | 35 | 36 | // re-multiply the blendColor alpha in to blendColor, weight inputColor according to blendColor.a 37 | resultColor.rgb = (1 - blendColor.a) * inputColor.rgb + resultColor.rgb * blendColor.a; 38 | 39 | return resultColor; 40 | } 41 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/NegationEffect.ps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/WPFBlendModeEffectLibrary/ShaderSource/NegationEffect.ps -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/NormalEffect.fx: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------- 2 | // 3 | // WPF ShaderEffect HLSL -- NormalEffect 4 | // 5 | //-------------------------------------------------------------------------------------- 6 | 7 | sampler2D input : register(s0); 8 | sampler2D blend : register(s1); 9 | 10 | //-------------------------------------------------------------------------------------- 11 | // Pixel Shader 12 | //-------------------------------------------------------------------------------------- 13 | 14 | float4 main(float2 uv : TEXCOORD) : COLOR 15 | { 16 | float4 inputColor; 17 | inputColor = tex2D(input, uv); 18 | 19 | float4 blendColor; 20 | blendColor = tex2D(blend, uv); 21 | 22 | inputColor.rgb = (1 - blendColor.a) * inputColor.rgb + blendColor.rgb; 23 | 24 | return inputColor; 25 | } 26 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/NormalEffect.ps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/WPFBlendModeEffectLibrary/ShaderSource/NormalEffect.ps -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/OverlayEffect.fx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/WPFBlendModeEffectLibrary/ShaderSource/OverlayEffect.fx -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/OverlayEffect.ps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/WPFBlendModeEffectLibrary/ShaderSource/OverlayEffect.ps -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/PhoenixEffect.fx: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------- 2 | // 3 | // WPF ShaderEffect HLSL -- PhoenixEffect 4 | // 5 | //-------------------------------------------------------------------------------------- 6 | 7 | #define BlendPhoenix(base, blend) (min(base, blend) - max(base, blend) + float3(1.0, 1.0, 1.0)) 8 | 9 | sampler2D input : register(s0); 10 | sampler2D blend : register(s1); 11 | 12 | //-------------------------------------------------------------------------------------- 13 | // Pixel Shader 14 | //-------------------------------------------------------------------------------------- 15 | 16 | float4 main(float2 uv : TEXCOORD) : COLOR 17 | { 18 | float4 inputColor; 19 | inputColor = tex2D(input, uv); 20 | 21 | float4 blendColor; 22 | blendColor = tex2D(blend, uv); 23 | 24 | 25 | float4 resultColor; 26 | resultColor.a = inputColor.a; 27 | 28 | // un-premultiply the blendColor alpha out from blendColor 29 | blendColor.rgb = clamp(blendColor.rgb / blendColor.a, 0, 1); 30 | 31 | 32 | // apply the blend mode math 33 | resultColor.rgb = BlendPhoenix(inputColor, blendColor); 34 | 35 | 36 | // re-multiply the blendColor alpha in to blendColor, weight inputColor according to blendColor.a 37 | resultColor.rgb = (1 - blendColor.a) * inputColor.rgb + resultColor.rgb * blendColor.a; 38 | 39 | return resultColor; 40 | } 41 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/PhoenixEffect.ps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/WPFBlendModeEffectLibrary/ShaderSource/PhoenixEffect.ps -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/PinLightEffect.fx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/WPFBlendModeEffectLibrary/ShaderSource/PinLightEffect.fx -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/PinLightEffect.ps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/WPFBlendModeEffectLibrary/ShaderSource/PinLightEffect.ps -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/ReflectEffect.fx: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------- 2 | // 3 | // WPF ShaderEffect HLSL -- ReflectEffect 4 | // 5 | //-------------------------------------------------------------------------------------- 6 | 7 | #define BlendReflectf(base, blend) ((blend == 1.0) ? blend : min(base * base / (1.0 - blend), 1.0)) 8 | 9 | sampler2D input : register(s0); 10 | sampler2D blend : register(s1); 11 | 12 | //-------------------------------------------------------------------------------------- 13 | // Pixel Shader 14 | //-------------------------------------------------------------------------------------- 15 | 16 | float4 main(float2 uv : TEXCOORD) : COLOR 17 | { 18 | float4 inputColor; 19 | inputColor = tex2D(input, uv); 20 | 21 | float4 blendColor; 22 | blendColor = tex2D(blend, uv); 23 | 24 | 25 | float4 resultColor; 26 | resultColor.a = inputColor.a; 27 | 28 | // un-premultiply the blendColor alpha out from blendColor 29 | blendColor.rgb = clamp(blendColor.rgb / blendColor.a, 0, 1); 30 | 31 | 32 | // apply the blend mode math 33 | resultColor.r = BlendReflectf(inputColor.r, blendColor.r); 34 | resultColor.g = BlendReflectf(inputColor.g, blendColor.g); 35 | resultColor.b = BlendReflectf(inputColor.b, blendColor.b); 36 | 37 | 38 | // re-multiply the blendColor alpha in to blendColor, weight inputColor according to blendColor.a 39 | resultColor.rgb = (1 - blendColor.a) * inputColor.rgb + resultColor.rgb * blendColor.a; 40 | 41 | return resultColor; 42 | } 43 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/ReflectEffect.ps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/WPFBlendModeEffectLibrary/ShaderSource/ReflectEffect.ps -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/SaturationEffect.fx: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------- 2 | // 3 | // WPF ShaderEffect HLSL -- SaturationEffect 4 | // 5 | // Saturation blend mode creates the result color by combining the luminance and hue 6 | // of the base color with the saturation of the blend color. 7 | // 8 | //-------------------------------------------------------------------------------------- 9 | 10 | sampler2D input : register(s0); 11 | sampler2D blend : register(s1); 12 | 13 | //-------------------------------------------------------------------------------------- 14 | // Pixel Shader 15 | //-------------------------------------------------------------------------------------- 16 | 17 | float3 RGBToHSL(float3 color) 18 | { 19 | float3 hsl; 20 | 21 | float fmin = min(min(color.r, color.g), color.b); 22 | float fmax = max(max(color.r, color.g), color.b); 23 | float delta = fmax - fmin; 24 | float maxplusmin = fmax + fmin; 25 | 26 | // set luminance 27 | hsl.z = maxplusmin / 2.0; 28 | 29 | if (delta == 0.0) 30 | { 31 | // a gray color, set hue and satuation to 0 32 | hsl.x = 0.0; 33 | hsl.y = 0.0; 34 | } 35 | else 36 | { 37 | // not a gray color 38 | 39 | // set saturation 40 | if (hsl.z < 0.5) 41 | hsl.y = delta / (maxplusmin); 42 | else 43 | hsl.y = delta / (2.0 - maxplusmin); 44 | 45 | if (color.r == fmax) 46 | hsl.x = ((color.g - color.b) / delta); 47 | else if (color.g == fmax) 48 | hsl.x = 2.0 + ((color.b - color.r) / delta); 49 | else if (color.b == fmax) 50 | hsl.x = 4.0 + ((color.r - color.g) / delta); 51 | 52 | hsl.x = hsl.x / 6.0; 53 | 54 | if (hsl.x < 0.0) 55 | hsl.x += 1.0; 56 | } 57 | 58 | return hsl; 59 | } 60 | 61 | float HueToRGB(float temp1, float temp2, float temp3) 62 | { 63 | if (temp3 < 0.0) 64 | temp3 += 1.0; 65 | else if (temp3 > 1.0) 66 | temp3 -= 1.0; 67 | 68 | float rgbComponent; 69 | 70 | if ((6.0 * temp3) < 1.0) 71 | rgbComponent = temp1 + (temp2 - temp1) * 6.0 * temp3; 72 | else if ((2.0 * temp3) < 1.0) 73 | rgbComponent = temp2; 74 | else if ((3.0 * temp3) < 2.0) 75 | rgbComponent = temp1 + (temp2 - temp1) * ((2.0 / 3.0) - temp3) * 6.0; 76 | else 77 | rgbComponent = temp1; 78 | 79 | return rgbComponent; 80 | } 81 | 82 | float3 HSLToRGB(float3 hsl) 83 | { 84 | float3 rgb; 85 | 86 | if (hsl.y == 0.0) 87 | { 88 | rgb = float3(hsl.z, hsl.z, hsl.z); 89 | } 90 | else 91 | { 92 | float temp2; 93 | if (hsl.z < 0.5) 94 | temp2 = hsl.z * (1.0 + hsl.y); 95 | else 96 | temp2 = (hsl.y + hsl.z) - (hsl.y * hsl.z); 97 | 98 | float temp1 = 2.0 * hsl.z - temp2; 99 | 100 | rgb.r = HueToRGB(temp1, temp2, hsl.x + (1.0/3.0)); 101 | rgb.g = HueToRGB(temp1, temp2, hsl.x); 102 | rgb.b = HueToRGB(temp1, temp2, hsl.x - (1.0/3.0)); 103 | } 104 | 105 | return rgb; 106 | } 107 | 108 | float3 BlendSaturation(float3 base, float3 blend) 109 | { 110 | float3 baseHSL = RGBToHSL(base); 111 | return HSLToRGB(float3(baseHSL.x, RGBToHSL(blend).y, baseHSL.z)); 112 | } 113 | 114 | float4 main(float2 uv : TEXCOORD) : COLOR 115 | { 116 | float4 inputColor; 117 | inputColor = tex2D(input, uv); 118 | 119 | float4 blendColor; 120 | blendColor = tex2D(blend, uv); 121 | 122 | 123 | float4 resultColor; 124 | resultColor.a = inputColor.a; 125 | 126 | // un-premultiply the blendColor alpha out from blendColor 127 | blendColor.rgb = clamp(blendColor.rgb / blendColor.a, 0, 1); 128 | 129 | 130 | // apply the blend mode math 131 | resultColor.rgb = BlendSaturation(inputColor.rgb, blendColor.rgb); 132 | 133 | 134 | // re-multiply the blendColor alpha in to blendColor, weight inputColor according to blendColor.a 135 | resultColor.rgb = (1 - blendColor.a) * inputColor.rgb + resultColor.rgb * blendColor.a; 136 | 137 | return resultColor; 138 | } 139 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/SaturationEffect.ps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/WPFBlendModeEffectLibrary/ShaderSource/SaturationEffect.ps -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/ScreenEffect.fx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/WPFBlendModeEffectLibrary/ShaderSource/ScreenEffect.fx -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/ScreenEffect.ps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/WPFBlendModeEffectLibrary/ShaderSource/ScreenEffect.ps -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/SoftLightEffect.fx: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------- 2 | // 3 | // WPF ShaderEffect HLSL -- SoftLightEffect 4 | // 5 | //-------------------------------------------------------------------------------------- 6 | 7 | #define BlendSoftLightf(base, blend) ((blend < 0.5) ? (2.0 * base * blend + base * base * (1.0 - 2.0 * blend)) : (sqrt(base) * (2.0 * blend - 1.0) + 2.0 * base * (1.0 - blend))) 8 | 9 | sampler2D input : register(s0); 10 | sampler2D blend : register(s1); 11 | 12 | float4 main(float2 uv : TEXCOORD) : COLOR 13 | { 14 | float4 inputColor; 15 | inputColor = tex2D(input, uv); 16 | 17 | float4 blendColor; 18 | blendColor = tex2D(blend, uv); 19 | 20 | 21 | float4 resultColor; 22 | resultColor.a = inputColor.a; 23 | 24 | // un-premultiply the blendColor alpha out from blendColor 25 | blendColor.rgb = clamp(blendColor.rgb / blendColor.a, 0, 1); 26 | 27 | 28 | // apply the blend mode math 29 | resultColor.r = BlendSoftLightf(inputColor.r, blendColor.r); 30 | resultColor.g = BlendSoftLightf(inputColor.g, blendColor.g); 31 | resultColor.b = BlendSoftLightf(inputColor.b, blendColor.b); 32 | 33 | 34 | // re-multiply the blendColor alpha in to blendColor, weight inputColor according to blendColor.a 35 | resultColor.rgb = (1 - blendColor.a) * inputColor.rgb + resultColor.rgb * blendColor.a; 36 | 37 | return resultColor; 38 | } 39 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/SoftLightEffect.ps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/WPFBlendModeEffectLibrary/ShaderSource/SoftLightEffect.ps -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/VividLightEffect.fx: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------- 2 | // 3 | // WPF ShaderEffect HLSL -- VividLightEffect 4 | // 5 | //-------------------------------------------------------------------------------------- 6 | 7 | #define BlendColorDodgef(base, blend) ((blend == 1.0) ? blend : min(base / (1.0 - blend), 1.0)) 8 | #define BlendColorBurnf(base, blend) ((blend == 0.0) ? blend : max((1.0 - ((1.0 - base) / blend)), 0.0)) 9 | #define BlendVividLightf(base, blend) ((blend < 0.5) ? BlendColorBurnf(base, (2.0 * blend)) : BlendColorDodgef(base, (2.0 * (blend - 0.5)))) 10 | 11 | sampler2D input : register(s0); 12 | sampler2D blend : register(s1); 13 | 14 | //-------------------------------------------------------------------------------------- 15 | // Pixel Shader 16 | //-------------------------------------------------------------------------------------- 17 | 18 | float4 main(float2 uv : TEXCOORD) : COLOR 19 | { 20 | float4 inputColor; 21 | inputColor = tex2D(input, uv); 22 | 23 | float4 blendColor; 24 | blendColor = tex2D(blend, uv); 25 | 26 | 27 | float4 resultColor; 28 | resultColor.a = inputColor.a; 29 | 30 | // un-premultiply the blendColor alpha out from blendColor 31 | blendColor.rgb = clamp(blendColor.rgb / blendColor.a, 0, 1); 32 | 33 | 34 | // apply the blend mode math 35 | resultColor.r = BlendVividLightf(inputColor.r, blendColor.r); 36 | resultColor.g = BlendVividLightf(inputColor.g, blendColor.g); 37 | resultColor.b = BlendVividLightf(inputColor.b, blendColor.b); 38 | 39 | 40 | // re-multiply the blendColor alpha in to blendColor, weight inputColor according to blendColor.a 41 | resultColor.rgb = (1 - blendColor.a) * inputColor.rgb + resultColor.rgb * blendColor.a; 42 | 43 | return resultColor; 44 | } 45 | -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/ShaderSource/VividLightEffect.ps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cplotts/WPFSLBlendModeFx/c4f0ff0039a759078f46d41d5356fabed14f352e/WPFBlendModeEffectLibrary/ShaderSource/VividLightEffect.ps -------------------------------------------------------------------------------- /WPFBlendModeEffectLibrary/WPFBlendModeEffectLibrary.csproj.vspscc: -------------------------------------------------------------------------------- 1 | "" 2 | { 3 | "FILE_VERSION" = "9237" 4 | "ENLISTMENT_CHOICE" = "NEVER" 5 | "PROJECT_FILE_RELATIVE_PATH" = "" 6 | "NUMBER_OF_EXCLUDED_FILES" = "0" 7 | "ORIGINAL_PROJECT_FILE_PATH" = "" 8 | "NUMBER_OF_NESTED_PROJECTS" = "0" 9 | "SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" 10 | } 11 | -------------------------------------------------------------------------------- /WPFSLBlendModeFx.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 11.00 2 | # Visual Studio 2010 3 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E86BFE46-0740-4037-B4E7-19F563310102}" 4 | ProjectSection(SolutionItems) = preProject 5 | BackgroundEffectBehavior.png = BackgroundEffectBehavior.png 6 | BlendModes.psd = BlendModes.psd 7 | BlendModes2.psd = BlendModes2.psd 8 | BlendModesOpacityTester.psd = BlendModesOpacityTester.psd 9 | H.design = H.design 10 | HelloWorld.design = HelloWorld.design 11 | HelloWorldColorBurn600.png = HelloWorldColorBurn600.png 12 | HOnImage.png = HOnImage.png 13 | HOnImage600.png = HOnImage600.png 14 | HOnImageColorBurn.png = HOnImageColorBurn.png 15 | HOnImageColorBurn600.png = HOnImageColorBurn600.png 16 | HOnImageColorBurn600NoCigar.png = HOnImageColorBurn600NoCigar.png 17 | HOnImageColorBurn600Success.png = HOnImageColorBurn600Success.png 18 | PhotoshopMathFP.hlsl = PhotoshopMathFP.hlsl 19 | EndProjectSection 20 | EndProject 21 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ColorPicker", "ColorPicker\ColorPicker.csproj", "{ED67A75F-5F76-43A8-9CD0-171212D599CB}" 22 | EndProject 23 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPFBlendModeEffectLibrary", "WPFBlendModeEffectLibrary\WPFBlendModeEffectLibrary.csproj", "{25F23180-F1BE-42F2-A58E-7F77BB03A987}" 24 | EndProject 25 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPFTestHarness", "WPFTestHarness\WPFTestHarness.csproj", "{C174652D-C12B-445D-8F80-10DF64FDB92A}" 26 | EndProject 27 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.DwayneNeed", "Microsoft.DwayneNeed\Microsoft.DwayneNeed.csproj", "{80A10B86-6615-4440-93B0-C943DF5B8693}" 28 | EndProject 29 | Global 30 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 31 | Debug|Any CPU = Debug|Any CPU 32 | Release|Any CPU = Release|Any CPU 33 | EndGlobalSection 34 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 35 | {ED67A75F-5F76-43A8-9CD0-171212D599CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 36 | {ED67A75F-5F76-43A8-9CD0-171212D599CB}.Debug|Any CPU.Build.0 = Debug|Any CPU 37 | {ED67A75F-5F76-43A8-9CD0-171212D599CB}.Release|Any CPU.ActiveCfg = Release|Any CPU 38 | {ED67A75F-5F76-43A8-9CD0-171212D599CB}.Release|Any CPU.Build.0 = Release|Any CPU 39 | {25F23180-F1BE-42F2-A58E-7F77BB03A987}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 40 | {25F23180-F1BE-42F2-A58E-7F77BB03A987}.Debug|Any CPU.Build.0 = Debug|Any CPU 41 | {25F23180-F1BE-42F2-A58E-7F77BB03A987}.Release|Any CPU.ActiveCfg = Release|Any CPU 42 | {25F23180-F1BE-42F2-A58E-7F77BB03A987}.Release|Any CPU.Build.0 = Release|Any CPU 43 | {C174652D-C12B-445D-8F80-10DF64FDB92A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 44 | {C174652D-C12B-445D-8F80-10DF64FDB92A}.Debug|Any CPU.Build.0 = Debug|Any CPU 45 | {C174652D-C12B-445D-8F80-10DF64FDB92A}.Release|Any CPU.ActiveCfg = Release|Any CPU 46 | {C174652D-C12B-445D-8F80-10DF64FDB92A}.Release|Any CPU.Build.0 = Release|Any CPU 47 | {80A10B86-6615-4440-93B0-C943DF5B8693}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 48 | {80A10B86-6615-4440-93B0-C943DF5B8693}.Debug|Any CPU.Build.0 = Debug|Any CPU 49 | {80A10B86-6615-4440-93B0-C943DF5B8693}.Release|Any CPU.ActiveCfg = Release|Any CPU 50 | {80A10B86-6615-4440-93B0-C943DF5B8693}.Release|Any CPU.Build.0 = Release|Any CPU 51 | EndGlobalSection 52 | GlobalSection(SolutionProperties) = preSolution 53 | HideSolutionNode = FALSE 54 | EndGlobalSection 55 | EndGlobal 56 | -------------------------------------------------------------------------------- /WPFSLBlendModeFx.vssscc: -------------------------------------------------------------------------------- 1 | "" 2 | { 3 | "FILE_VERSION" = "9237" 4 | "ENLISTMENT_CHOICE" = "NEVER" 5 | "PROJECT_FILE_RELATIVE_PATH" = "" 6 | "NUMBER_OF_EXCLUDED_FILES" = "0" 7 | "ORIGINAL_PROJECT_FILE_PATH" = "" 8 | "NUMBER_OF_NESTED_PROJECTS" = "0" 9 | "SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROJECT" 10 | } 11 | -------------------------------------------------------------------------------- /WPFTestHarness/App.xaml: -------------------------------------------------------------------------------- 1 |  7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /WPFTestHarness/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Windows; 7 | 8 | namespace WPFTestHarness 9 | { 10 | /// 11 | /// Interaction logic for App.xaml 12 | /// 13 | public partial class App : Application 14 | { 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /WPFTestHarness/BlueBulbWindow.xaml: -------------------------------------------------------------------------------- 1 |  12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 46 | 47 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /WPFTestHarness/BlueBulbWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Windows; 6 | using System.Windows.Controls; 7 | using System.Windows.Data; 8 | using System.Windows.Documents; 9 | using System.Windows.Input; 10 | using System.Windows.Media; 11 | using System.Windows.Media.Imaging; 12 | using System.Windows.Shapes; 13 | 14 | namespace WPFTestHarness 15 | { 16 | /// 17 | /// Interaction logic for BlueBulbWindow.xaml 18 | /// 19 | public partial class BlueBulbWindow : Window 20 | { 21 | public BlueBulbWindow() 22 | { 23 | InitializeComponent(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /WPFTestHarness/GradientContoursTestWindow.xaml: -------------------------------------------------------------------------------- 1 |  11 | 12 | 17 | 18 | 19 | 20 | 21 | 26 | 27 | 28 | 29 | 30 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 88 |