[android-developers] Re: Confusion about using Camera to take pictures from my application

2010-01-20 Thread Neil
I'm trying to do this too, except I want a full-sized picture.  I have
it working.  I'm using your code, but without all the extras (maybe
those extras are causing your error?)  My code:

File tmpFile = new File(Environment.getExternalStorageDirectory(),
tmp_ + String.valueOf(System.currentTimeMillis()) + 
.jpg);
Intent imgCapture = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
imgCapture.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tmpFile));

// in the activity result:
if (resultCode == Activity.RESULT_CANCELED) {
return;
}
try {
imageView.setImageBitmap(BitmapFactory.decodeStream(new
FileInputStream(tmpFile)));
} catch (Exception e) {
Log.e(Constants.LOG_TAG, Unable to load image content, e);
}
tmpFile.delete();

One problem with this is that my app doesn't have permission to delete
the temp file.  I can't point the camera to my app's files/ directory
because the Camera activity doesn't have access to my files.  Do you
know how to provide a content provider URI that both activities would
have read/write access to?  I haven't had the chance to read much
about content providers yet...

The other problem is, this will only return a 512x384 image.  Without
the EXTRA_OUTPUT the image returned is even smaller (192x256).  For
you, this might be okay.  You can probably scale the image down to
64x64 using some Bitmap or Matrix methods (not sure how to do that).

For me, this is unacceptable, and from what I can tell the only way to
get a full size image is to use the Camera API and ditch the Camera
activity altogether :-(.  See the comments here:
http://code.google.com/p/android/issues/detail?id=1480

Btw, if you are using the external storage to store the picture, you
may want to check that it exists first:

String storageState = Environment.getExternalStorageState();
if (!Environment.MEDIA_MOUNTED.equals(storageState)) {
// If there's no storage media, our intents won't work.
return;
}

Let me know if you find anything more!  I'm going to keep looking...

To everyone else reading this:
Is there a way to get a full sized picture from the Camera activity?
Or do I have to roll my own?  That would be SUPER lame.  If I do have
to make my own activity, can someone point me to some example code?
Thanks in advance!


-- Neil

On Jan 7, 7:10 am, rben ray.benja...@gmail.com wrote:
 I've been trying to write an application that uses the Camera App to
 take a picture. So far, the only thing I've been able to get back
 successfully is a tiny bitmap picture. I've found several other posts
 related to this topic that have code that is reported to work, but it
 does not work for me. I'm hoping someone can steer me in the right
 direction.

 Below is the code I am using currently, but it causes the application
 to blow up.

         private void takePicture(final int x, final int y, String
 description) {
                 // create a file on the SD card
                 File file = new 
 File(Environment.getExternalStorageDirectory(),
                                 tmp_ + 
 String.valueOf(System.currentTimeMillis()) +
                                 .jpg);
                 // Create the URI that tells the camera where to put the 
 picture.
                 mOutputFileUri = Uri.fromFile(file);
                 statusLine.setText(URI =  + mOutputFileUri);
                 mIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE)
                         .putExtra(MediaStore.EXTRA_OUTPUT, mOutputFileUri)
                         .putExtra(PIC_X, x)  // x coordinate of square
                         .putExtra(PIC_Y, y)  // y coordinate of square
                         .putExtra(PIC_DESCRIP,description)
                         .putExtra(return-data, true)
                         ;
                 startActivityForResult(mIntent, PIC_FROM_CAMERA);
         }

 Ultimately, I want to be able to get the picture back and do two
 things with it: create a 64x64 icon that is displayed by the Android
 application, and upload the picture to a web application.

 Thank you for any help or advice you can give.
 Oh, btw, I'm running this on the emulator using Android 2.0

 Thanks,
   Ray
-- 
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

[android-developers] Re: Confusion about using Camera to take pictures from my application

2010-01-20 Thread Streets Of Boston
I'm going to upload a camera app in the market soon that does provide
the Uri to full-sized images. If your intent requires an in-memory
bitmap, it is still a small-sized image (100KBytes in size), but the
Uri should point to the size of the image as it was taken by the
camera.

I'm still writing up the help text and testing it out on various
devices.

On Jan 19, 2:18 pm, Neil ntr...@gmail.com wrote:
 I'm trying to do this too, except I want a full-sized picture.  I have
 it working.  I'm using your code, but without all the extras (maybe
 those extras are causing your error?)  My code:

 File tmpFile = new File(Environment.getExternalStorageDirectory(),
                         tmp_ + String.valueOf(System.currentTimeMillis()) + 
 .jpg);
 Intent imgCapture = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
 imgCapture.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tmpFile));

 // in the activity result:
 if (resultCode == Activity.RESULT_CANCELED) {
         return;}

 try {
         imageView.setImageBitmap(BitmapFactory.decodeStream(new
 FileInputStream(tmpFile)));} catch (Exception e) {

         Log.e(Constants.LOG_TAG, Unable to load image content, e);}

 tmpFile.delete();

 One problem with this is that my app doesn't have permission to delete
 the temp file.  I can't point the camera to my app's files/ directory
 because the Camera activity doesn't have access to my files.  Do you
 know how to provide a content provider URI that both activities would
 have read/write access to?  I haven't had the chance to read much
 about content providers yet...

 The other problem is, this will only return a 512x384 image.  Without
 the EXTRA_OUTPUT the image returned is even smaller (192x256).  For
 you, this might be okay.  You can probably scale the image down to
 64x64 using some Bitmap or Matrix methods (not sure how to do that).

 For me, this is unacceptable, and from what I can tell the only way to
 get a full size image is to use the Camera API and ditch the Camera
 activity altogether :-(.  See the comments 
 here:http://code.google.com/p/android/issues/detail?id=1480

 Btw, if you are using the external storage to store the picture, you
 may want to check that it exists first:

 String storageState = Environment.getExternalStorageState();
 if (!Environment.MEDIA_MOUNTED.equals(storageState)) {
         // If there's no storage media, our intents won't work.
         return;

 }

 Let me know if you find anything more!  I'm going to keep looking...

 To everyone else reading this:
 Is there a way to get a full sized picture from the Camera activity?
 Or do I have to roll my own?  That would be SUPER lame.  If I do have
 to make my own activity, can someone point me to some example code?
 Thanks in advance!

 -- Neil

 On Jan 7, 7:10 am, rben ray.benja...@gmail.com wrote:



  I've been trying to write an application that uses the Camera App to
  take a picture. So far, the only thing I've been able to get back
  successfully is a tiny bitmap picture. I've found several other posts
  related to this topic that have code that is reported to work, but it
  does not work for me. I'm hoping someone can steer me in the right
  direction.

  Below is the code I am using currently, but it causes the application
  to blow up.

          private void takePicture(final int x, final int y, String
  description) {
                  // create a file on the SD card
                  File file = new 
  File(Environment.getExternalStorageDirectory(),
                                  tmp_ + 
  String.valueOf(System.currentTimeMillis()) +
                                  .jpg);
                  // Create the URI that tells the camera where to put the 
  picture.
                  mOutputFileUri = Uri.fromFile(file);
                  statusLine.setText(URI =  + mOutputFileUri);
                  mIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE)
                          .putExtra(MediaStore.EXTRA_OUTPUT, mOutputFileUri)
                          .putExtra(PIC_X, x)  // x coordinate of square
                          .putExtra(PIC_Y, y)  // y coordinate of square
                          .putExtra(PIC_DESCRIP,description)
                          .putExtra(return-data, true)
                          ;
                  startActivityForResult(mIntent, PIC_FROM_CAMERA);
          }

  Ultimately, I want to be able to get the picture back and do two
  things with it: create a 64x64 icon that is displayed by the Android
  application, and upload the picture to a web application.

  Thank you for any help or advice you can give.
  Oh, btw, I'm running this on the emulator using Android 2.0

  Thanks,
    Ray- Hide quoted text -

 - Show quoted text -
-- 
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