Search code examples
androidpngandroid-camera2camera2

Camera2 PNG capture


I am working on a camera application using the Camera2 API. I am able to capture a RAW (.dng file) and jpg. I saw that it is possible to take a PNG photo on the Camera FV-5 Application and I would like to do the same. I am able to get the ByteBuffer of the RAW and each pixel's individual RGB value (if this helps...). PNG capture is important as I want to make this feature possible so I have something in between RAW and JPEG (RAW's is too large, JPEG compresses too much. PNG is a lossless compression format.). Thanks!


Solution

  • If you have the bitmap, which it sounds like you do, then you can save it as a PNG:

    OutputStream imageStream = new FileOutputStream("yourImage.png");
    yourImageBitmap.compress(CompressFormat.PNG, 100, imageStream);
    imageStream.close();