mirror of
https://github.com/Stone-Red-Code/DesktopMagic.git
synced 2026-09-04 08:56:15 +02:00
Improve performance of plugin window bitmap rendering
This commit is contained in:
@@ -175,6 +175,8 @@ public partial class PluginWindow : Window, IPluginWindow
|
|||||||
bitmapData.Scan0, bitmapData.Stride * bitmapData.Height, bitmapData.Stride);
|
bitmapData.Scan0, bitmapData.Stride * bitmapData.Height, bitmapData.Stride);
|
||||||
|
|
||||||
bitmap.UnlockBits(bitmapData);
|
bitmap.UnlockBits(bitmapData);
|
||||||
|
|
||||||
|
bitmapSource.Freeze();
|
||||||
return bitmapSource;
|
return bitmapSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,7 +223,11 @@ public partial class PluginWindow : Window, IPluginWindow
|
|||||||
border.CornerRadius = new CornerRadius(settings.Theme.CornerRadius);
|
border.CornerRadius = new CornerRadius(settings.Theme.CornerRadius);
|
||||||
|
|
||||||
pluginClassInstance?.OnThemeChanged();
|
pluginClassInstance?.OnThemeChanged();
|
||||||
pluginClassInstance?.Application.UpdateWindow();
|
|
||||||
|
if (pluginClassInstance?.UpdateInterval is 0 or > 500)
|
||||||
|
{
|
||||||
|
pluginClassInstance.Application.UpdateWindow();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExecuteSource()
|
private void ExecuteSource()
|
||||||
@@ -392,7 +398,11 @@ public partial class PluginWindow : Window, IPluginWindow
|
|||||||
element.OnValueChanged += () =>
|
element.OnValueChanged += () =>
|
||||||
{
|
{
|
||||||
pluginClassInstance?.OnSettingsChanged();
|
pluginClassInstance?.OnSettingsChanged();
|
||||||
pluginClassInstance?.Application.UpdateWindow();
|
|
||||||
|
if (pluginClassInstance?.UpdateInterval is 0 or > 500)
|
||||||
|
{
|
||||||
|
pluginClassInstance.Application.UpdateWindow();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
settingElements.Add(settingElement);
|
settingElements.Add(settingElement);
|
||||||
@@ -583,11 +593,13 @@ public partial class PluginWindow : Window, IPluginWindow
|
|||||||
_ => BitmapScalingMode.Unspecified
|
_ => BitmapScalingMode.Unspecified
|
||||||
};
|
};
|
||||||
|
|
||||||
//Update Image
|
// Update Image
|
||||||
Dispatcher.Invoke(() =>
|
BitmapSource frozenSource = BitmapToImageSource(result);
|
||||||
|
|
||||||
|
_ = Dispatcher.BeginInvoke(() =>
|
||||||
{
|
{
|
||||||
RenderOptions.SetBitmapScalingMode(image, renderOptions);
|
RenderOptions.SetBitmapScalingMode(image, renderOptions);
|
||||||
image.Source = BitmapToImageSource(result);
|
image.Source = frozenSource;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user