Właśnie zakończyłem działanie kamery i cudownie zapisuję dane. Co zrobić po wykonaniu zdjęcia zrobione:Android Obróć zdjęcie przed zapisaniem
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();
}
}
Co chcę już jako komentarzu podany w powyższym kodzie. Nie chcę, aby obraz został zapisany do pliku, ale został obrócony, a następnie zapisany! Dzięki!
// EDIT: Jaka jestem obecnie do (działa, ale nadal działa w kwestii pamięci o duże zdjęcia)
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();
możliwe duplikat [Android: Jak obrócić bitmapę na punkcie środkowym] (http://stackoverflow.com/questions/4166917/android-how-to-rotate-a-bitmap-on-a -center-point) – slayton
Nah, nie tak naprawdę, to więcej o tym, jak obracać i oszczędzać później – androidavid
W porządku moje rozwiązanie wydaje się działać - czyszczenie projektu ... – androidavid