xamarin.android - Xamarin Android 等效项-> Java:Color.Red(int)
问题描述
有谁知道什么相当于:Java代码:
int pixel = source.getPixel(x, y);
int g = (int) (0.3 * Color.red(pixel) + 0.59 * Color.green(pixel) + 0.11 * Color.blue(pixel)); //grayscale shade corresponding to rgb
在 Xamarin Android 中。
解决方案
我想这可能是你想要的:
int pixel = source.GetPixel(x, y);
int g = (int) (0.3 * Color.GetRedComponent(pixel) + 0.59 * Color.GetGreenComponent(pixel) + 0.11 * Color.GetBlueComponent(pixel));
这也会产生相同的结果:
Color pixelColor = new Color(source.GetPixel(x, y));
int g1 = (int) (0.3 * pixelColor.R + 0.59 * pixelColor.G + 0.11 * pixelColor.B);
顺便说一句,还有 GetAlphaComponent():
int A = Color.GetAlphaComponent(pixel);
推荐阅读
- javascript - 在 React 中插入内容后,防止关注 Expand More 按钮
- azure-active-directory - 无法通过 microsoft graph api 从头开始创建团队
- php - 升级PHP后Apache无法运行
- java - 如何使用@InjectMocks 注入相同类型的依赖项?
- python - 我想要一个新数组,其值可被 3 或 5 整除,仅使用布尔掩码
- javascript - 是否可以在模态中显示外部网页内容?(AngularJS+Bootstrap+Html+CSS)
- javascript - 使用超时时 document.execCommand("copy") 不起作用
- java - 警报确认,javaFx
- oracle - 如何在 Crystal Reports 中水平显示列的内容?
- python - 如何使用 Python 从文本文件中过滤没有元音的单词?