diff --git a/src/DesktopMagic/Plugin/PluginWindow.xaml b/src/DesktopMagic/Plugin/PluginWindow.xaml index d845850..2b39491 100644 --- a/src/DesktopMagic/Plugin/PluginWindow.xaml +++ b/src/DesktopMagic/Plugin/PluginWindow.xaml @@ -13,12 +13,11 @@ SizeChanged="Window_SizeChanged" Closing="Window_Closing" ContentRendered="Window_ContentRendered" - x:Name="window"> - + diff --git a/src/DesktopMagic/Plugin/PluginWindow.xaml.cs b/src/DesktopMagic/Plugin/PluginWindow.xaml.cs index e433d46..a63b32b 100644 --- a/src/DesktopMagic/Plugin/PluginWindow.xaml.cs +++ b/src/DesktopMagic/Plugin/PluginWindow.xaml.cs @@ -1,6 +1,9 @@ using DesktopMagicPluginAPI; +using DesktopMagicPluginAPI.Drawing; using DesktopMagicPluginAPI.Inputs; + using Microsoft.Win32; + using System; using System.Collections.Generic; using System.Diagnostics; @@ -251,9 +254,18 @@ namespace DesktopMagic if (result is not null) { + BitmapScalingMode renderOptions = pluginClassInstance.RenderQuality switch + { + RenderQuality.High => BitmapScalingMode.HighQuality, + RenderQuality.Low => BitmapScalingMode.LowQuality, + RenderQuality.Performance => BitmapScalingMode.NearestNeighbor, + _ => BitmapScalingMode.Unspecified + }; + //Update Image Dispatcher.Invoke(() => { + RenderOptions.SetBitmapScalingMode(image, renderOptions); image.Source = BitmapToImageSource(result); }); } diff --git a/src/DesktopMagicPluginAPI/DesktopMagicPluginAPI.md b/src/DesktopMagicPluginAPI/DesktopMagicPluginAPI.md index 7840ec4..7acedab 100644 --- a/src/DesktopMagicPluginAPI/DesktopMagicPluginAPI.md +++ b/src/DesktopMagicPluginAPI/DesktopMagicPluginAPI.md @@ -46,12 +46,17 @@ - [Right](#F-DesktopMagicPluginAPI-Inputs-MouseButton-Right 'DesktopMagicPluginAPI.Inputs.MouseButton.Right') - [Plugin](#T-DesktopMagicPluginAPI-Plugin 'DesktopMagicPluginAPI.Plugin') - [Application](#P-DesktopMagicPluginAPI-Plugin-Application 'DesktopMagicPluginAPI.Plugin.Application') + - [RenderQuality](#P-DesktopMagicPluginAPI-Plugin-RenderQuality 'DesktopMagicPluginAPI.Plugin.RenderQuality') - [UpdateInterval](#P-DesktopMagicPluginAPI-Plugin-UpdateInterval 'DesktopMagicPluginAPI.Plugin.UpdateInterval') - [Main()](#M-DesktopMagicPluginAPI-Plugin-Main 'DesktopMagicPluginAPI.Plugin.Main') - [OnMouseClick(position,mouseButton)](#M-DesktopMagicPluginAPI-Plugin-OnMouseClick-System-Drawing-Point,DesktopMagicPluginAPI-Inputs-MouseButton- 'DesktopMagicPluginAPI.Plugin.OnMouseClick(System.Drawing.Point,DesktopMagicPluginAPI.Inputs.MouseButton)') - [OnMouseMove(position)](#M-DesktopMagicPluginAPI-Plugin-OnMouseMove-System-Drawing-Point- 'DesktopMagicPluginAPI.Plugin.OnMouseMove(System.Drawing.Point)') - [OnMouseWheel(position,Delta)](#M-DesktopMagicPluginAPI-Plugin-OnMouseWheel-System-Drawing-Point,System-Int32- 'DesktopMagicPluginAPI.Plugin.OnMouseWheel(System.Drawing.Point,System.Int32)') - [Start()](#M-DesktopMagicPluginAPI-Plugin-Start 'DesktopMagicPluginAPI.Plugin.Start') +- [RenderQuality](#T-DesktopMagicPluginAPI-Drawing-RenderQuality 'DesktopMagicPluginAPI.Drawing.RenderQuality') + - [High](#F-DesktopMagicPluginAPI-Drawing-RenderQuality-High 'DesktopMagicPluginAPI.Drawing.RenderQuality.High') + - [Low](#F-DesktopMagicPluginAPI-Drawing-RenderQuality-Low 'DesktopMagicPluginAPI.Drawing.RenderQuality.Low') + - [Performance](#F-DesktopMagicPluginAPI-Drawing-RenderQuality-Performance 'DesktopMagicPluginAPI.Drawing.RenderQuality.Performance') - [Slider](#T-DesktopMagicPluginAPI-Inputs-Slider 'DesktopMagicPluginAPI.Inputs.Slider') - [#ctor(min,max,value)](#M-DesktopMagicPluginAPI-Inputs-Slider-#ctor-System-Double,System-Double,System-Double- 'DesktopMagicPluginAPI.Inputs.Slider.#ctor(System.Double,System.Double,System.Double)') - [Maximum](#P-DesktopMagicPluginAPI-Inputs-Slider-Maximum 'DesktopMagicPluginAPI.Inputs.Slider.Maximum') @@ -508,6 +513,13 @@ The plugin class. Informations about the main application. + +### RenderQuality `property` + +##### Summary + +Gets or sets the render quality of the bitmap image. + ### UpdateInterval `property` @@ -582,6 +594,38 @@ Occurs once when the pugin gets activated. This method has no parameters. + +## RenderQuality `type` + +##### Namespace + +DesktopMagicPluginAPI.Drawing + +##### Summary + +Specifies which render quality is used to display the bitmap images. + + +### High `constants` + +##### Summary + +Slower then [Low](#F-DesktopMagicPluginAPI-Drawing-RenderQuality-Low 'DesktopMagicPluginAPI.Drawing.RenderQuality.Low') but produces higher quality output. + + +### Low `constants` + +##### Summary + +Faster then [High](#F-DesktopMagicPluginAPI-Drawing-RenderQuality-High 'DesktopMagicPluginAPI.Drawing.RenderQuality.High') but produces lower quality output. + + +### Performance `constants` + +##### Summary + +Provides performance benefits over [Low](#F-DesktopMagicPluginAPI-Drawing-RenderQuality-Low 'DesktopMagicPluginAPI.Drawing.RenderQuality.Low') + ## Slider `type` diff --git a/src/DesktopMagicPluginAPI/DesktopMagicPluginAPI.xml b/src/DesktopMagicPluginAPI/DesktopMagicPluginAPI.xml index a485ff1..2974b49 100644 --- a/src/DesktopMagicPluginAPI/DesktopMagicPluginAPI.xml +++ b/src/DesktopMagicPluginAPI/DesktopMagicPluginAPI.xml @@ -53,6 +53,26 @@ structure that specifies the upper-left corner of the drawn text. The specified width. + + + Specifies which render quality is used to display the bitmap images. + + + + + Slower then but produces higher quality output. + + + + + Faster then but produces lower quality output. + + + + + Provides performance benefits over + + Represents a button control. @@ -311,6 +331,11 @@ Gets or sets the interval, expressed in milliseconds, at which to call the method. + + + Gets or sets the render quality of the bitmap image. + + Occurs once when the pugin gets activated. diff --git a/src/DesktopMagicPluginAPI/Drawing/RenderQuality.cs b/src/DesktopMagicPluginAPI/Drawing/RenderQuality.cs new file mode 100644 index 0000000..41a8e75 --- /dev/null +++ b/src/DesktopMagicPluginAPI/Drawing/RenderQuality.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DesktopMagicPluginAPI.Drawing +{ + /// + /// Specifies which render quality is used to display the bitmap images. + /// + public enum RenderQuality + { + /// + /// Slower then but produces higher quality output. + /// + High, + + /// + /// Faster then but produces lower quality output. + /// + Low, + + /// + /// Provides performance benefits over + /// + Performance + } +} \ No newline at end of file diff --git a/src/DesktopMagicPluginAPI/Plugin.cs b/src/DesktopMagicPluginAPI/Plugin.cs index abac60e..46351a2 100644 --- a/src/DesktopMagicPluginAPI/Plugin.cs +++ b/src/DesktopMagicPluginAPI/Plugin.cs @@ -1,4 +1,6 @@ -using DesktopMagicPluginAPI.Inputs; +using DesktopMagicPluginAPI.Drawing; +using DesktopMagicPluginAPI.Inputs; + using System; using System.Drawing; @@ -35,6 +37,11 @@ namespace DesktopMagicPluginAPI /// public virtual int UpdateInterval { get; set; } = 1000; + /// + /// Gets or sets the render quality of the bitmap image. + /// + public virtual RenderQuality RenderQuality { get; set; } = RenderQuality.High; + /// /// Occurs once when the pugin gets activated. ///