BTW, how reliable is this shutter trick?

http://code.google.com/android/reference/android/hardware/Camera.ShutterCallback.html

states that onShutter() is called *after* taking the picture, but
before the data is available. Now that data must be derived from the
picture, right? So setting picture size in onShutter() formally
shouldn't work - but hey, this is Android. ;-)

In my app I wait until the onPreviewFrame() preview callback has been
entered, thus taking care of the way that the G1 preview
initialization messes with (read: silently overrules some) parameter
initializations of the application, then I apply my desired
setPictureSize() such that it will not be overruled by the G1 camera
code, and after that I do a takePicture() (in my case without a
shutter callback). Then again I wait because takePicture() is
asynchronous, this time until the onPictureTaken() picture callback
has been entered, to make sure that the picture has really really been
taken and not just been ordered, and only then I save the JPEG file.
Yes, this is how ugly things get if you want to use the G1 camera...

On Nov 17, 11:48 pm, Alvin Yates <[EMAIL PROTECTED]> wrote:
> Okay, so I figured out what the problem with a series of back-and-
> forth emails with blindfold.
>
> Basically, the camera API is asynchronous to the point where my
> setting the parameters on onSurfaceChanged() is not actually
> occurring  as it should be.  In short, you need to have something that
> will definitely complete, and a method that calls startPreview()
> doesn't guarantee that at all.  So in a series of emails, the idea
> came up to monitor the preview frames, set up through locking a thread
> on a boolean.  I had a few issues with synchronization and the phone
> locking up (Although I think I broke the Camera hardware itself when I
> was doing so), but got around it by making a Camera.Shutter callback,
> which takes care of the "method needs to complete" problem on top of
> being fairly easily to do (by doing the following):
>
> ====
>         private Camera.ShutterCallback sillyDelay = new Camera.ShutterCallback
> () {
>
>                 public void onShutter() {
>                         Camera.Parameters p = mCamera.getParameters();
>
>                         p.setPictureSize(CAM_W, CAM_H);
>                         p.setPictureFormat(PixelFormat.JPEG);
>
>                         mCamera.setParameters(p);
>                 }
>         };
> ====
>
>         @Override
>         public boolean onKeyDown(int keycode, KeyEvent event){
>                 if (keycode == KeyEvent.KEYCODE_CAMERA ||
>                         keycode == KeyEvent.KEYCODE_DPAD_CENTER) {
>                         mCamera.takePicture(sillyDelay, null, writeMe);
>                 }
>
>                 super.onKeyDown(keycode, event);
>                 return true;
>         }
> ====

--~--~---------~--~----~------------~-------~--~----~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to