Note that there are some explanatory texts on larger screens.

plurals
  1. POSave picture while Camera is in stopPreview mode
    primarykey
    data
    text
    <p><strong>BACKGROUND</strong> Hey so I have a camera that I have implemented myself in code. This means I access and control the camera hardware and use it to save pictures. I can save the picture using the Camera.takePicture() function when the camera is <strong>running</strong>: running means Camera.startPreview();</p> <p><strong>PROBLEM</strong> My problem is that I want to be able to save the image also when the camera image is <strong>frozen</strong>: frozen is when Camera.stopPreview(); is called.When frozen I can see the image in my layout but how do I access it? Where is the image saved so that I might be able to modify it later?</p> <p>Thanks in advance!</p> <p><strong>------------------Update 1</strong></p> <pre><code> jpeg bla; public class jpeg implements PictureCallback{ public void onPictureTaken(byte[] data, Camera camera) { g_data = data; } } </code></pre> <p>This is part of my code. Here I am trying to write the data that would originally be saved to a global variable. However the value of g_data remains null and I am unable to set a breakpoint inside the onPictureTaken() call back function. </p> <p><strong>------------------Update 2</strong></p> <pre><code>FileOutputStream outStream = null; try { // generate the folder File imagesFolder = new File(Environment.getExternalStorageDirectory(), "MirrorMirror"); if( !imagesFolder.exists() ) { imagesFolder.mkdirs(); } // generate new image name SimpleDateFormat formatter = new SimpleDateFormat("HH_mm_ss"); Date now = new Date(); String fileName = "image_" + formatter.format(now) + ".jpg"; // create outstream and write data File image = new File(imagesFolder, fileName); outStream = new FileOutputStream(image); outStream.write(data); outStream.close(); Log.d(TAG, "onPictureTaken - wrote bytes: " + data.length); } catch (FileNotFoundException e) { // &lt;10&gt; //Toast.makeText(ctx, "Exception #2", Toast.LENGTH_LONG).show(); e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally {} </code></pre> <p>I used this code previously to save the file from the camera onPictureTaken() function. The key here is the byte[] data which I need to save and save later. However like I said I just get a null when I check it in the debugger.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload