Color.rgb 在 Android 中做什么?
我正在制作一个使用相机进行实时图像处理的应用程序。我已经用 Java 编写了代码,现在我正在尝试将该代码移植到本机代码以加快速度。 Java 代码的一个重要部分是使用 Color.rgb(来自 android.Graphics 库) 方法将我的像素强度数组转换为“color-ints”(文档给出的描述)。具体的代码行是:
Color.rgb(pixel, pixel, pixel)
其中像素是 0 到 255 之间的整数。然后我使用 drawBitmap 方法将此颜色整数数组绘制到画布上。是的,我意识到这会产生黑白图像,因为这就是我所需要的。
现在我需要在我的 C 代码中将像素强度转换为颜色整数,并且我无法使用上述方法,因为 C 中没有库。我什至不确定颜色整数是什么。如果有人可以向我描述 Color.rgb 方法对强度值的实际作用,我就可以在 C 中手动编码。干杯。
I'm making an app that does some real time image processing using the camera. I've written code in Java and now I'm trying to port that code over to native code to speed things up. An essential part of the Java code is to use the Color.rgb (from the android.Graphics library) method to convert my array of pixel intensities into "color-ints" (description given by the documentation). The specific line of code is:
Color.rgb(pixel, pixel, pixel)
where pixel is an integer between 0 and 255. I then use the drawBitmap method to draw this array of color-ints to a canvas. Yes I realise that this results in a B&W image because that is what I need.
Now I need to convert the pixel intensities into color-ints in my C code, and I can't use the above method as there is no library in C. I'm not sure what color-ints even are in the first place. If someone could describe to me what the Color.rgb method actually does to an intensity value, I could then manually code that in C. Cheers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看一下:
来源
Take a look:
Source
“color-int”是打包的 32 位 (ARGB) 颜色值,其中每个分量本身都是 8 位。
rgb
是将离散值转换为“color-int”的帮助器。查看alpha
、red
、green
和blue
文档提供了足够的信息来推断这一点,而无需查看源代码对于 rgb 本身。快乐编码。
A "color-int" is the packed 32-bit (ARGB) color value, where each component is itself 8 bits.
rgb
is a helper to turn the discreet values into the "color-int". Looking at thealpha
,red
,green
andblue
documentation provides enough information to deduce this without looking at the source forrgb
itself.Happy coding.