system.windows.media

Getting Geometry length

烂漫一生 提交于 2020-01-03 17:27:08
问题 Does anyone know an efficient way of getting the length of a WPF geometry in Pixels? I know that geometries in WPF are vector based and therefore do not really have a pixellength. But it has to be possible to get the length based on the visible drawn image. I mean if I draw some geometries in a 1024x800 pixel image it has to be possible to get the length of those. Am I wrong here or is there any possible and efficient way of getting these informations? Thank you in advance! Michael 回答1: I

Saving Windows.Media.Drawing with BmpBitmapEncoder black image - how to remove alpha?

南楼画角 提交于 2019-12-25 03:54:44
问题 I'm using SVG# (http://sharpvectors.codeplex.com/), to batch convert SVG files to other formats. The SVG images being converted are black line drawings with no background. I've little experience with WPF or the System.Windows.Media namespace, so please excuse me if this is a basic question. I'm using a modified version of the ImageSvgConverter from SVG#, which accepts a System.Windows.Media.Drawing object, which is then converted using a System.Windows.Media encoder ( BmpBitmapEncoder ,

How to make specific color darken or lighten based on value in wpf?

匆匆过客 提交于 2019-12-23 07:28:45
问题 I am developing wpf application. I am having the instance of Color object in C#. Suppose I have instance of red Color object i.e. Color c = Color.FromArgb(255,255,0,0) Now suppose that I have one value which ranges from 1 to 10. So based on this value I want to change the color of the 'c' object. I want light red for 1 and dark red for 10. The light red becomes the dark as the value increases from 1. How can I do this in C# for wpf application ? Can you please provide me any code or link

Convert System.Drawing.Color to System.Windows.Media.Color [duplicate]

我是研究僧i 提交于 2019-12-18 01:32:21
问题 This question already has answers here : How to convert from System.Drawing.Color to System.Windows.Media.Color? (3 answers) Closed 3 years ago . System.Drawing.Color drawRedColor = System.Drawing.Color.Red; System.Windows.Media.Color mediaColor = ?drawRedColor.ToMediaColor();? 回答1: How about: using MColor = System.Windows.Media.Color; using DColor = System.Drawing.Color; ... public static MColor ToMediaColor(this DColor color) { return MColor.FromArgb(color.A, color.R, color.G, color.B); }

C# MediaPlayer.MediaEnded event not firing

情到浓时终转凉″ 提交于 2019-12-12 01:58:18
问题 i have this little piece of C# code //Creates a MediaPlayer with the sound you want to play public static void PlaySound (Stream wavStream, string wavName, bool loop) { //Get the path for the file to play var path = GetFilePath(wavStream, wavName); var player = new MediaPlayer(); player.Open(new Uri(path)); player.MediaEnded += loop ? new EventHandler(MediaEndedLoop) : new EventHandler(MediaEndedDestroy); player.Play(); players.Add(player); names.Add(wavName); } I dont know why but

System.Windows.Media.DrawingVisual.RenderOpen() erroring after a time

可紊 提交于 2019-12-08 14:50:29
问题 Use Case: I'm using WPF to dynamically overlay text on images within a web context. Solution: I'm using a DrawingContext from a DrawingVisual (wrapped in a using statement) to draw the original bitmap and overlay text. Problem: After a few thousand requests the [DrawingVisual].RenderOpen() method starts refusing to execute and throws the following exception: The system cannot find the file specified System.ComponentModel.Win32Exception UInt16 RegisterClassEx(WNDCLASSEX_D) at MS.Win32

Convert System.Drawing.Color to System.Windows.Media.Color [duplicate]

橙三吉。 提交于 2019-11-28 22:44:48
This question already has an answer here: How to convert from System.Drawing.Color to System.Windows.Media.Color? 3 answers System.Drawing.Color drawRedColor = System.Drawing.Color.Red; System.Windows.Media.Color mediaColor = ?drawRedColor.ToMediaColor();? How about: using MColor = System.Windows.Media.Color; using DColor = System.Drawing.Color; ... public static MColor ToMediaColor(this DColor color) { return MColor.FromArgb(color.A, color.R, color.G, color.B); } EDIT: Fixed the 'unpacking' of the ARGB. System.Windows.Media.Color mediaColor = System.Windows.Media.Color.FromRgb(Color.Red.R,