简体   繁体   English

每像素16位灰度位图

[英]16 bit per pixel grayscale bitmap

From my camera, I get a byte array. 从我的相机,我得到一个字节数组。 Each two bytes (two elements of the array) define one pixel. 每两个字节(数组的两个元素)定义一个像素。 If I understand correctly, the most of the current devices support only 256 shades of gray. 如果我理解正确,当前大多数设备仅支持256级灰度。 So, for my image I need only MSB. 因此,对于我的图像,我只需要MSB。 The problem is that this is a streaming video, and creating a new array for a bitmap made up of every second byte takes a long time. 问题在于这是一个流视频,要为由第二个字节组成的位图创建新数组需要很长时间。 Is it possible to output a "degraded" picture (16 bit -> 8 bit) using some classes? 是否可以使用某些类输出“降级”图片(16位-> 8位)?

Edit: If there are class that can create bitmap for grayscale with 16 bit per pixel it also interesting for me 编辑:如果有可以创建每像素16位的灰度位图的类,这对我来说也很有趣

To speed up the convert processing, you might think use 为了加快转换处理速度,您可能会考虑使用

OpenGL ES OpenGL ES

Use texture to render your color bitmap to pbuffer surface and create a grayscale version of the image in your glsl. 使用纹理将颜色位图渲染到pbuffer表面,并在glsl中创建图像的灰度版本。 the value can calculate from RGB representation like this luminance = 0.21 * R + 0.72 * G + 0.07 * B . 该值可以根据RGB表示来计算,例如luminance = 0.21 * R + 0.72 * G + 0.07 * B This method take a lot of work to setup GLES environment and the load/read bitmap might not very efficient. 此方法需要大量的工作来设置GLES环境,并且加载/读取位图可能不是很有效。

Renderscript 渲染脚本

Write a simple renderscript kernel to extract the MSB from original bits, then output the result to bitmap. 编写一个简单的渲染脚本内核,以从原始位中提取MSB,然后将结果输出到位图。 This method could make the bits extraction procedure faster than the direct implementation in Java I guess. 我猜这种方法可以使位提取过程比直接用Java实现更快。

If you don't know renderscript before, take a look of the official documentation here , it's not so complicated and won't take you too much time to accomplish your task. 如果您以前不了解renderscript,请查看此处的官方文档,它并不那么复杂,也不会花费您太多时间来完成您的任务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM