Note that there are some explanatory texts on larger screens.

plurals
  1. POdoing photos with the camera and save them in a specific folder
    primarykey
    data
    text
    <p>I'm working on an android application which allows the user to take some photos using the android camera.The user takes this pictures for competing to a photo contest.So, he takes a few photos, which should be saved into a specific destination and after a while he loops between those photos and decide with which one he will compete to the photo contest. Well, for that the photos should be saved on a specific folder not in the gallery among other photos which are not for the contest. Currently, I'm just saving the photos to SDcard and I don't know how should I do to save them in a certain folder.</p> <p>I must say that I have already built my own camera but still don't know how to act when comes to saving the images.</p> <p>And here is how it looks like:</p> <pre><code>public class EditPhoto extends Activity implements SurfaceHolder.Callback, OnClickListener { static final int FOTO_MODE = 0; private static final String TAG = "CameraTest"; Camera mCamera; boolean mPreviewRunning = false; private Context mContext = this; public void onCreate(Bundle icicle) { super.onCreate(icicle); //doing things } @Override protected void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); } Camera.PictureCallback mPictureCallback = new Camera.PictureCallback(){ public void onPictureTaken(byte[] imageData, Camera c) { if (imageData != null) { Intent mIntent = new Intent(); StoreByteImage(mContext, imageData, 50, "ImageName"); mCamera.startPreview(); Bundle b = new Bundle(); b.putByteArray("imageData", imageData); Intent i = new Intent(mContext, ImageDisplayActivity.class); i.putExtras(b); startActivity(i); setResult(FOTO_MODE, mIntent); finish(); } } }; protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); } protected void onStop() { Log.e(TAG, "onStop"); super.onStop(); } public void surfaceCreated(SurfaceHolder holder) { Log.e(TAG, "surfaceCreated"); mCamera = Camera.open(); } public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) { Log.e(TAG, "surfaceChanged"); if (mPreviewRunning) { mCamera.stopPreview(); } Camera.Parameters p = mCamera.getParameters(); List&lt;Size&gt; sizes = p.getSupportedPictureSizes(); p.setPreviewSize(640, 480); p.setPictureSize(213,350); mCamera.setParameters(p); try { mCamera.setPreviewDisplay(holder); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } mCamera.startPreview(); mPreviewRunning = true; } public void surfaceDestroyed(SurfaceHolder holder) { Log.e(TAG, "surfaceDestroyed"); mCamera.stopPreview(); mPreviewRunning = false; mCamera.release(); } private SurfaceView mSurfaceView; private SurfaceHolder mSurfaceHolder; public void onClick(View arg0) { mCamera.takePicture(null, mPictureCallback, mPictureCallback); } public static boolean StoreByteImage(Context mContext, byte[] imageData, int quality, String expName) { File sdImageMainDirectory = new File("/sdcard"); FileOutputStream fileOutputStream = null; String nameFile; try { BitmapFactory.Options options=new BitmapFactory.Options(); options.inSampleSize = 5; Bitmap myImage = BitmapFactory.decodeByteArray(imageData, 0, imageData.length,options); fileOutputStream = new FileOutputStream(sdImageMainDirectory.toString() +"/image.jpg"); BufferedOutputStream bos = new BufferedOutputStream(fileOutputStream); myImage.compress(CompressFormat.JPEG, quality, bos); bos.flush(); bos.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return true; } } </code></pre> <p>If you could point me in the right direction I would apppreciate it.Thanks</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