Acabo de terminar la actividad de mi cámara y está guardando maravillosamente los datos. ¿Qué hago después de tomar la fotografía:Android Girar imagen antes de guardar
protected void savePictureData() {
try {
FileOutputStream fs = new FileOutputStream(this.photo);
fs.write(this.lastCamData);
fs.close(); //okay, wonderful! file is just written to the sdcard
//---------------------
//---------------------
//TODO in here: dont save just the file but ROTATE the image and then save it!
//---------------------
//---------------------
Intent data = new Intent(); //just a simple intent returning some data...
data.putExtra("picture_name", this.fname);
data.putExtra("byte_data", this.lastCamData);
this.setResult(SAVED_TOOK_PICTURE, data);
this.finish();
} catch (IOException e) {
e.printStackTrace();
this.IOError();
}
}
Lo que quiero es ya como comentario dada en el código de seguridad. No quiero que la imagen solo se guarde en un archivo, sino que se rotará y luego se guardará. ¡Gracias!
// EDITAR: De lo que estoy actualmente hasta (Obras, pero aún se encuentra con problemas de memoria con imágenes grandes)
byte[] pictureBytes;
Bitmap thePicture = BitmapFactory.decodeByteArray(this.lastCamData, 0, this.lastCamData.length);
Matrix m = new Matrix();
m.postRotate(90);
thePicture = Bitmap.createBitmap(thePicture, 0, 0, thePicture.getWidth(), thePicture.getHeight(), m, true);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
thePicture.compress(CompressFormat.JPEG, 100, bos);
pictureBytes = bos.toByteArray();
FileOutputStream fs = new FileOutputStream(this.photo);
fs.write(pictureBytes);
fs.close();
Intent data = new Intent();
data.putExtra("picture_name", this.fname);
data.putExtra("byte_data", pictureBytes);
this.setResult(SAVED_TOOK_PICTURE, data);
this.finish();
posible duplicado de [Android: Cómo rotar un mapa de bits en un punto central] (http://stackoverflow.com/questions/4166917/android-how-to-rotate-a-bitmap-on-a -center-point) – slayton
nah, no realmente, es más acerca de cómo rotar y guardar después – androidavid
bien mi solución parece funcionar - limpié el proyecto ... – androidavid