Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Issue with decodeBitmap with ACTION_IMAGE_CAPTURE
    primarykey
    data
    text
    <p>I am trying to have my app take a picture and return that picture for use. However, it is throwing an exception both in the emulator and on a Nexus One.</p> <p>Here is my code:</p> <pre><code>private File temporaryCameraFile = new File("/sdcard/tmp.bmp"); </code></pre> <p>When chose from the menu to take a picture:</p> <pre><code>Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); cameraIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(temporaryCameraFile)); startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST); </code></pre> <p>in onActivityResult()</p> <pre><code>if(resultCode == RESULT_OK){ Bitmap cameraPicture = decodeFile(temporaryCameraFile); // resize to fit screen and add to queue to be drawn if (cameraPicture != null) if ((cameraPicture.getWidth() &gt; 0) &amp;&amp; (cameraPicture.getHeight() &gt; 0)) page.SetBackground(ResizeImageToFit(cameraPicture)); } </code></pre> <p>decodeFile()</p> <pre><code>private Bitmap decodeFile(File f){ try { //decode image size BitmapFactory.Options o = new BitmapFactory.Options(); o.inJustDecodeBounds = true; BitmapFactory.decodeStream(new FileInputStream(f),null,o); //decode with inSampleSize o.inJustDecodeBounds = false; Bitmap retval = BitmapFactory.decodeStream(new FileInputStream(f), null, o); return retval; } catch (FileNotFoundException e) { Log.e("decodeFile()", e.toString()); return null; } } </code></pre> <p>In decodeFile(), the first decode properly returns the bounds. However, when I call it the second time, I get the following error on both the emulator and the Nexus One. I tried updating the decodeFile to only do the main decode without the inJustDecodeBounds method, but that failed as well. Also, I have pulled the file off of the device manually and it is a valid bitmap.</p> <pre><code> 09-20 15:30:58.711: ERROR/AndroidRuntime(332): Caused by: java.lang.IllegalArgumentException: width and height must be &gt; 0 </code></pre> <p>Any help would be appreciated.</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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.
    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