Reputation: 113
After pressing capture Button
, image should save in sdcard, it is taking snapshot but not saving the image with that,
Then how can I put the capture button wherever I want? I have an overlay in the Imageview
and I need to put the button over the overlay.
Upvotes: 0
Views: 231
Reputation: 157487
stream=new ByteArrayOutputStream();
temBitmap=Bitmap.createBitmap(bmp);
temBitmap.compress(Bitmap.CompressFormat.JPEG,100, stream);
path+=String.format(
getString(R.string._sdcard_d_jpg),
System.currentTimeMillis());
outStream = new FileOutputStream(path+extension); // <9>
outStream.write(stream.toByteArray());
outStream.close();
change the above snippet this way:
path+=String.format(
getString(R.string._sdcard_d_jpg),
System.currentTimeMillis());
outStream = new FileOutputStream(path+extension); // <9>
temBitmap=Bitmap.createBitmap(bmp);
temBitmap.compress(Bitmap.CompressFormat.JPEG,100, outStream);
outStream.close();
temBitmap.recycle()
Upvotes: 0
Reputation: 7082
Use this one to store image in sd card
public void save(Bitmap image)
{
File sdcard = Environment.getExternalStorageDirectory();
File f = new File (sdcard, imagename);
FileOutputStream out=null;
try {
out = new FileOutputStream(f);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
image.compress(Bitmap.CompressFormat.PNG, 90, out);
try {
out.flush();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
Upvotes: 1
Reputation: 1244
int picture callback, use like this
jpegCallback = new PictureCallback() {
public void onPictureTaken(byte[] data, Camera camera) {
camera.startPreview();
FileOutputStream outStream = null;
try {
outStream = new FileOutputStream(
"/mnt/sdcard/myphoto.jpg");
outStream.write(data);
outStream.close();
Log.d("Log", "onPictureTaken - wrote bytes: " + data.length);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
}
Log.d("Log", "onPictureTaken - jpeg");
}
};
Upvotes: 1