【问题标题】:Problems with Color class (System.Drawing) in UWP on Raspberry PiRaspberry Pi 上 UWP 中颜色类(System.Drawing)的问题
【发布时间】:2019-09-04 06:37:27
【问题描述】:

我很难在运行 Windows 10 IoT 的 Raspberry Pi 上使用 Color 类实现一些基本操作。在我通过 rgb 数据实例化一个 Color 对象之后 GetBrightness() 或 GetSaturation() 等基本方法会导致 SEHException。

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

在调试期间在 Visual Studio 的“立即窗口”中键入操作会产生所需的结果。我什至不知道从哪里开始找到实际问题。

我正在使用带有 Windows 10 IoT Core 17763(也是项目构建设置)的 Raspberry Pi 2b,并尝试在其上运行 C# UWP-Project。

我尝试了几个目标版本并更新了我的机器。到目前为止没有帮助。

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

如前所述,即时窗口中的结果似乎是合理的并且至少有效。为什么这不在代码中运行。在即时窗口中输入的代码实际处理在哪里?

【问题讨论】:

  • UWP 中可能需要 Windows.UI.Color
  • 嗨,它不提供 GetHue() 等。至少我找不到它。

标签: c# uwp raspberry-pi windows-10-iot-core


【解决方案1】:

System.Drawing 在 Windows 通用应用程序中是不可能的,它是使用 GDI+ 的 .NET 命名空间。 您可以使用SharpDX,它为 Direct2D、DirectWrite 和 Windows 映像组件 (WIC) 提供包装器。 GetHue 方法包含在ColorBGRA.cs 中。

【讨论】:

  • 感谢您的宝贵时间。直到现在我还没有意识到我应该仔细检查 VS 建议我的 using 是否在整个 UWP 命名空间中实际可用。不过,基本颜色操作在 UWP 中也很有用。我会实现你所指的类
猜你喜欢
  • 2019-02-06
  • 2018-01-08
  • 1970-01-01
  • 2012-09-14
  • 1970-01-01
  • 2022-01-17
  • 1970-01-01
  • 2021-02-17
  • 1970-01-01
相关资源
最近更新 更多