从ImageReader将图像数据格式检索到BufferBytes?

时间:2017-10-24 08:35:11

标签: java android bytebuffer

下面我带了我的代码,我在ByteBuffer中保存了ByteBuffer字节。 使用这种方法,我可以提取图像数据,如大小,颜色空间,像素大小,填充,数据类型等?

如果我去调试哪里可以找到这些信息?

    ImageReader.OnImageAvailableListener readerListener = new ImageReader.OnImageAvailableListener () {
                @Override
                public void onImageAvailable (ImageReader reader)
                    Image imagereader = null;
                    
                        imagereader = reader.acquireLatestImage ();
                        ImagePlane plane = imagereader.getPlanes () [0];
                        ByteBuffer buffer = plane.getBuffer ();
                        byte [] bytes = new byte [buffer.capacity ()];
                        buffer.get (bytes);
                        save (bytes);
                        imagereader.close ();

FileOutputStream fileOutputStream = null;
            try {
                fileOutputStream = new FileOutputStream(mImageFileName);
                fileOutputStream.write(bytes);
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                mImage.close();
}

然后我会用它来通过C ++函数管理这些信息。 提前致谢。

0 个答案:

没有答案