1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| Camera camera = Camera.open();
SurfaceView vue = new SurfaceView(context);
try {
camera.setPreviewDisplay(vue.getHolder());
} catch (IOException e) {
Toast.makeText(context, "apercu raté",Toast.LENGTH_LONG).show();
}
camera.startPreview();
PictureCallback jpegcallback = new PictureCallback() {
@Override
public void onPictureTaken(byte[] data, Camera camera)
{
FileOutputStream out = null;
try
{
out = new FileOutputStream("/retouchées/test.jpeg");
out.write(data);
out.flush();
out.close();
} catch (FileNotFoundException e) {
Toast.makeText(context, "file erreur",Toast.LENGTH_LONG).show();
} catch (IOException e) {
// TODO Auto-generated catch block
Toast.makeText(context, "IO exeption",Toast.LENGTH_LONG).show();
}
}
};
camera.takePicture(null, jpegcallback, jpegcallback);
camera.release(); |
Partager