gpt4 book ai didi

c# - 在 WPF-Desktop 程序中设置每像素位数

转载 作者:行者123 更新时间:2023-11-30 22:03:56 26 4
gpt4 key购买 nike

在 WPF 中使用渐变时,我注意到了丑陋的 strip 问题,并且发现解决方案是将“每像素位数”属性设置为 32。问题是该属性似乎仅适用于 Windows Phone,即无法在桌面设备的程序上运行,因为试图添加 this string。在 ApplicationManifest 中似乎没有做任何事情。

有谁知道我是否/如何设置此属性?

谢谢。

我绘制渐变的函数:

public LinearGradientBrush getGradient(Color c1, Color c2, double opacity)
{
LinearGradientBrush gradient = new LinearGradientBrush();
gradient.StartPoint = new Point(0, 0);
gradient.EndPoint = new Point(1, 1);
gradient.GradientStops.Add(new GradientStop(c1, 0.0));
gradient.GradientStops.Add(new GradientStop(c2, 1.0));
gradient.Opacity = opacity;
return gradient;
}

我从 AlbumCover 中的两种最主要的颜色中提取渐变。您可以在窗口的左上角看到两种颜色。然后我用这个调用 getGradient 函数:

getGradient(Colors[0], Colors[1], 0.5); // 0.5 is dynamic depending on the brightness of those colors. Tried with 1 opacity but it's still the same.

这是示例图片(PNG 格式,未压缩上传)

如您所见,正在出现 strip 化。还有更糟糕的例子,但我不记得 Cover 给出的是什么。

请注意 Image1 的 AlbumCover 上没有 strip 。尽管上面有渐变。

最佳答案

通过快速搜索,我发现了一些建议,即问题可能只是视觉效果,这是由于定义颜色和渐变工作方式的每个 R、G 和 B channel 只有 256 个值造成的。如果您尝试用渐变覆盖大面积区域,它将把它分成更小的区域,这些区域充满纯色,相邻区域之间略有变化。此外,还有一种名为 Mach bands 的视错觉。这使得区域的边界更加明显。

查看这些链接以获取更多信息和一些建议的解决方案:

关于c# - 在 WPF-Desktop 程序中设置每像素位数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25632808/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com