如何将字节数组转换为可以在Android屏幕上显示的图像?

如何将字节数组转换为可以在Android屏幕上显示的图像?,android,arrays,video-streaming,Android,Arrays,Video Streaming,我有一个字节数组形式的原始单色数据(每个像素一个字节) 获取此数据并将其显示为屏幕图像的最低延迟方法是什么 (它需要足够快,才能以每秒30帧的速度显示720x480帧的视频。) 这不是重复,也不能使用decodeByteArray解决,因为此字节数组包含原始数据,而不是decodeByteArray要求的“压缩图像数据的字节数组”。可能有一种方法涉及BitMap.createBitmap Bitmap bmp = BitmapFactory.decodeByteArray(byteArray,

我有一个字节数组形式的原始单色数据(每个像素一个字节)

获取此数据并将其显示为屏幕图像的最低延迟方法是什么

(它需要足够快,才能以每秒30帧的速度显示720x480帧的视频。)


这不是重复,也不能使用
decodeByteArray
解决,因为此字节数组包含原始数据,而不是decodeByteArray要求的“压缩图像数据的字节数组”。

可能有一种方法涉及
BitMap.createBitmap

Bitmap bmp = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
ImageView image = (ImageView) findViewById(R.id.imageView1);

image.setImageBitmap(Bitmap.createScaledBitmap(bmp, image.getWidth(),
                image.getHeight(), false)));

here you can set image on imageview after converting byte array to bitmap and then scaling that bitmap and setting on imageview
createBitmap
added in API level 1

Bitmap createBitmap (int[] colors, 
                int width, 
                int height, 
                Bitmap.Config config)

Returns a immutable bitmap with the specified width and height, with each pixel value set to the corresponding value in the colors array. Its initial density is as per getDensity(). The newly created bitmap is in the sRGB color space.

可能重复@NileshRathod No,此字节数组包含原始数据,而不是decodeByteArray要求的“压缩图像数据的字节数组”。请选中此项,尝试创建具有正确分辨率的空位图。然后逐个填充像素。操作简单,但速度可能较慢。字节数组包含原始单色数据,而不是
decodeByteArray
所需的“压缩图像数据字节数组”。