Search code examples
androidimagecamerapreview

Is there a simple way to turn the byte array from the camera's onPreviewFrame into a picture in android?


I ask if there is a simple way because there is a google issue report saying that using decodeByteArray isn't possible. But that report originated in 2008 and I was hoping there was a solution not posted on there. The method listed on the issue report was to decode the format yourself, but I'd prefer to not have to put that in and slow down the program. Any help at all would be appreciated.


Solution

  • The easiest way is to create a BufferedImage the following way:

    Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0. data.length);
    

    data is the byte array.