I use the camera code for Android after I take the picture, the byte [] of the imageData parameter is null, I donβt know why.
package com.pictures; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.PixelFormat; import android.graphics.Bitmap.CompressFormat; import android.hardware.Camera; import android.os.Bundle; import android.util.Log; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; import android.view.Window; import android.view.WindowManager; import android.view.View.OnClickListener; import android.view.View.OnTouchListener; public class CamaraView 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); Log.e(TAG, "onCreate"); Bundle extras = getIntent().getExtras(); getWindow().setFormat(PixelFormat.TRANSLUCENT); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.main); mSurfaceView = (SurfaceView) findViewById(R.id.surface_camera); mSurfaceView.setOnClickListener(this); mSurfaceHolder = mSurfaceView.getHolder(); mSurfaceHolder.addCallback(this); mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } @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(); setResult(FOTO_MODE, mIntent); finish(); } } }; protected void onResume() { Log.e(TAG, "onResume"); super.onResume(); } 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");
max
source share