In my code I have my own camera and it works and saves the pictures properly. First I call:
myCamera.takePicture(null, null, jpegCallBack);
Then I want to save the picture and display it in the same activity I'm now. So in the jpegCallBack I have (fullPic is my ImageView):
try {
FileOutputStream fos = new FileOutputStream(pictureFile);
fos.write(data);
fos.close();
Media.getBitmap(getContentResolver(), Uri.fromFile(pictureFile) );
String image_string = Uri.fromFile(pictureFile).toString();
bm = BitmapFactory.decodeFile(image_string);
fullPic.setImageBitmap(bm);
} catch ...
But it doesn't work, the first time I press the Shot Button, it saves the file and continues displaying the camera. Sometimes when I take the second one app stops.
I've also tried with this:
fullPic.setImageURI(Uri.fromFile(pictureFile));
and it says: "Bitmap too large to be uploaded into a texture (4608x2592, max=4096x4096)"
I can reduce the size of the displayed image if it is necessary (but not the saved one), but I don't know how to do it.
In the AndroidManifest I have permission for both WRITE and READ. My XML is like this:
<LL>
<RL>
<FrameLayout></FL> for the Camera Preview
<Button></> To shot the picture
<ImageView></> Here I want to show the picture taken
</RL>
</LL>
Why doesn't it work? Any ideas to display it? I have been looking another stackoverflow links but I don't find the solution. If you need more data/code, please, let me know, I tried to summarize to make it the clearest possible.
Thank you!
Edit:
This is the call of jpegCallBack:
private PictureCallback jpegCallBack = new PictureCallback() {
@Override
public void onPictureTaken(byte[] data, Camera camera)
Maybe I can so the image directly from that data in some way. Can I? I tried this way but it breaks:
bm = BitmapFactory.decodeByteArray(data, 0, data.length);
fullPic.setImageBitmap(bm);
LogCat: On the blue line I press the shot button
NullPointerException, is it possible that it occurs because I'm using a Samsung? In this thread they say that Samsung has problems with this: Capture Image from Camera and Display in Activity