I've pasted all code below, but the problem bit is as follows
- Code: Select all
Bitmap bm = BitmapFactory.decodeByteArray(data, 0, data.length);
if(takenPicture != null) { takenPicture.recycle(); }
takenPicture = bm;
imageView.setImageBitmap(takenPicture);
What I'm tryint to do is display the image just taken for a user to say keep or take again. Right now I'm trying to show the image up in an imageview which presents two problems
1) The image shows up in the image view horizontally (Yikes!)
2) Always running out of memory.
Would appreciate any help in resolving either problem!
- Code: Select all
[syntax="java"] Camera.PictureCallback photoCallback = new Camera.PictureCallback() {
public void onPictureTaken(byte[] data, Camera camera) {
// TODO Auto-generated method stub
FileOutputStream fos;
try
{
Bitmap bm = BitmapFactory.decodeByteArray(data, 0, data.length);
if(takenPicture != null) { takenPicture.recycle(); }
takenPicture = bm;
imageView.setImageBitmap(takenPicture);
String fileUrl = MediaStore.Images.Media.insertImage(getContentResolver(), bm, "Camera Image", "Context Cam");
if(fileUrl == null)
{
Log.d("Still", "Image Insert Failed");
return;
} else
{
Uri picUri = Uri.parse(fileUrl);
sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, picUri));
}
}
catch(Exception e)
{
Log.d("PicturePerfect", "Error Picture: ", e);
}
camera.startPreview();
}
};[syntax="java"]


