将 byte[] BGRA 数组转换为更有用/更快速的内容 (JAVA)
我有一个包含 BGRA 栅格数据的 byte[] 数组(例如,第一个字节 = 蓝色分量,第二个 = 绿色,第五个 = 下一个像素,蓝色),并且想使用它。
具体来说,是否有一个 Java 类已经被设计来包装这样的东西?我想知道,因为我想让我的代码尽可能整洁/正确,如果 Java 已经有一个更快的编译版本,那么我会选择它。
更具体地说,我想将 byte[] 数组转换为 2 个数组,其中 BGR1[] + BGR2[] = BGR,并且 A1 = A2 = A。有什么建议吗?
我当然可以为此编写原始代码,但也许有一种更简洁/更快的方法。
I have a byte[] array that contains BGRA raster data (e.g. first byte = blue component, second = green, fifth = next pixel, blue) and would like to play with it.
Specifically, is there a Java class that's already designed to wrap something like this? I'm wondering, because I'd like to make my code as neat/correct as possible, and if Java already has a compiled version that's faster, then I'd go with that.
Even more specifically, I want to transform the byte[] array into 2 arrays, where BGR1[] + BGR2[] = BGR, and A1 = A2 = A. Any suggestions?
I could of course just write raw code for this, but perhaps there is a neater/faster way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道这是否很快,但它肯定更有用。我的源数据数组来自 Kinect 的颜色流,使用 J4KSDK。
我使用此方法的目标是读取图像的二进制字节。我确信您可以对其进行修改以供自己使用。
I don't know if this is speedy, but it is sure more useful. My source data array came from the Color Stream from Kinect, using J4KSDK.
My goal with this method was to read the binary bytes of an image. I'm sure you can modify it for your own uses.
您可以看到这个其他问题,其中有以下答案良好的 Java 图像处理库。
You could see this other question which has responses for good Java image manipulation libraries.