views:

23

answers:

0

Hi, The code below is executed as the jpeg picture callback after TakePicture is called. If I save data to disk, it is a 1280x960 jpeg. I've tried to change the picture size but that's not possible as no smaller size is supported. JPEG is the only available picture format.

 PictureCallback jpegCallback = new PictureCallback() {
  public void onPictureTaken(byte[] data, Camera camera) {
   FileOutputStream out = null;
   Bitmap bm = BitmapFactory.decodeByteArray(data, 0, data.length); 
   Bitmap sbm = Bitmap.createScaledBitmap(bm, 640, 480, false);

data.Length is something like 500k as expected. After executing BitmapFactory.decodeByteArray(), bm has a height and width of -1 so it appears the operation is failing.

  • It's unclear to me if Bitmap can handle jpeg data. I would think not but I have seem some code examples that seem to indicate it is.
  • Does data need to be in bitmap format before decoding and scaling?
  • If so, how to do this?

Thanks!