Binary data works upto about 100KByte. Anything larger, you very
likely get that error.

For images in RGB_565, this is about 277 x 184 pixels max (277 x 184 *
2 = 101936)

On Feb 16, 4:17 am, Bart <bvandep...@gmail.com> wrote:
> Hi, I have a problem with an app that lets the user take a picture.
> I've posted it on some forums already, but nobody seems to recognize
> the problem. Hopefully someone here knows a solution :)
>
> I've put the code of taking a picture in a seperate activity. Then I
> call the camera intent from my main activity using activityForResult.
> In the camera intent, I use putExtra to return the camera image (as a
> byte[] without doing anything to it). But when the program transitions
> back from the camera intent to the parent intent that called it I get
> a Failed Binder Transaction error in the logcat because the byte[] is
> too big. But I don't understand this, because the image is not even
> taken using the maximum resolution :S
>
> The code of my camera intent is:
>
> package example.imaging.ape;
>
> import java.io.IOException;
> import java.util.Iterator;
> import java.util.Set;
>
> import android.app.Activity;
> import android.content.Intent;
> import android.graphics.Bitmap;
> import android.graphics.BitmapFactory;
> import android.graphics.PixelFormat;
> import android.hardware.Camera;
> import android.hardware.Camera.AutoFocusCallback;
> import android.os.Bundle;
> import android.util.Log;
> 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.OnTouchListener;
>
> public class TakePicture extends Activity implements
> SurfaceHolder.Callback{
>      Camera mCamera;
>      Boolean mPreviewRunning = false;
>      int imageLayoutHeight;
>      int imageLayoutWidth;
>
>     �...@override
>      public void onCreate(Bundle savedInstanceState) {
>           super.onCreate(savedInstanceState);
>
>           //setup camera surface
>           getWindow().setFormat(PixelFormat.TRANSLUCENT);
>           requestWindowFeature(Window.FEATURE_NO_TITLE);
>
> getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
> WindowManager.LayoutParams.FLAG_FULLSCREEN);
>           setContentView(R.layout.cameralayout);
>
>           SurfaceView mSurfaceView = (SurfaceView)
> findViewById(R.id.hist_surface_camera);
>           SurfaceHolder mSurfaceHolder = mSurfaceView.getHolder();
>           mSurfaceHolder.addCallback(this);
>
> mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
>           Bundle extras = getIntent().getExtras();
>           imageLayoutHeight = extras.getInt("layoutHeight");
>           imageLayoutWidth = extras.getInt("layoutWidth");
>
>           OnTouchListener touchListener = new View.OnTouchListener() {
>                public boolean onTouch(View v, MotionEvent e) {
>
>                     System.out.println("MAKING PICTURE");
>                     mCamera.autoFocus(cb);
>                     return false;
>                }
>           };
>
>           //setup touch listener
>           mSurfaceView.setOnTouchListener(touchListener);
>
>      }
>
>      AutoFocusCallback cb = new AutoFocusCallback() {
>           public void onAutoFocus(boolean success, Camera c) {
>                c.takePicture(null, null, mPictureCallback);
>           }
>      };
>
>      Camera.PictureCallback mPictureCallback = new
> Camera.PictureCallback() {
>           public void onPictureTaken(byte[] imageData, Camera c) {
>                System.out.println("Picture taken, now
> returning");
>                Intent resultIntent = new Intent();
>                resultIntent.putExtra("cameraImage", imageData);
>                System.out.println("put Extra");
>                setResult(Activity.RESULT_OK, resultIntent);
>                finish();
>           }
>      };
>
>      //initialize camera
>      public void surfaceCreated(SurfaceHolder holder) {
>           mCamera = Camera.open();
>      }
>
>      public void surfaceChanged(SurfaceHolder holder, int format, int
> w, int h) {
>           if (mPreviewRunning) {
>                mCamera.stopPreview();
>           }
>
>           Camera.Parameters p = mCamera.getParameters();
>
>           p.setPreviewSize(h, w);
>           System.out.println("PreviewSize: " + h + "," + w);
>           p.setPictureSize(h*3,w*3); // is around 1200x900
>           p.set("rotation", 90);
>           mCamera.setParameters(p);
>
>           try {
>                mCamera.setPreviewDisplay(holder);
>           } catch (IOException e) {
>                e.printStackTrace();
>           }
>
>           mCamera.startPreview();
>           mPreviewRunning = true;
>      }
>
>      public void surfaceDestroyed(SurfaceHolder holder) {
>           mCamera.stopPreview();
>           mPreviewRunning = false;
>           mCamera.release();
>      }
>
> }
>
> And this is how I call the camera activity:
>
> Intent intent = new Intent(mainActivity.this, TakePicture.class);
> intent.putExtra("layoutWidth",layoutWidth);
> intent.putExtra("layoutHeight",layoutHeight);
> startActivityForResult(intent,0);
>
> The onActivityResult is never reached because the error occurs during
> the transition between intents.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to