Problems with Color class (System.Drawing) in UWP on Raspberry Pi

1

I struggle to implement some basic operations with Color class on my Raspberry Pi running Windows 10 IoT. After I instantiate a Color object by rgb data basic methods like GetBrightness() or GetSaturation() lead to a SEHException.

Thrown exception: System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.

Typing the operation in the "immediate window" in Visual Studio during debugging yields the desired result though. I don't even know where to start to locate the actual issue.

I'm using a Raspberry Pi 2b with Windows 10 IoT Core 17763 (also project build setting), and trying to run an C# UWP-Project on it.

I tried several target versions and also updated my machine. Didn't help so far.

// using System.Drawing;
Color color1 = Color.FromArgb(x, y, z);                
float brt = color1.GetBrightness(); // <= Not passing this line
float sat = color1.GetSaturation();

Like mentioned, the results in immediate window seem plausible and works at least. Why this isn't also running in code. Where is the code actually processed, that is typed in the immediate window?

c#
uwp
raspberry-pi
windows-10-iot-core
asked on Stack Overflow Apr 13, 2019 by InGustice • edited Apr 14, 2019 by InGustice

1 Answer

0

System.Drawing is not possible in Windows Universal app, it is the .NET namespace for working with GDI+. You can make use of SharpDX which provides wrappers for Direct2D, DirectWrite, and the Windows Imaging Component (WIC). The GetHue method is included in ColorBGRA.cs.

answered on Stack Overflow Apr 15, 2019 by Michael Xu - MSFT

User contributions licensed under CC BY-SA 3.0