Android Повернуть изображение перед сохранением

Я только что закончил работу с камерой, и она прекрасно сохраняет данные. Что я делаю после того, как снимок сделан:

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();
    }

}

То, что я хочу, уже является комментарием, данным в коде выше. Я не хочу, чтобы изображение было просто сохранено в файл, а было повернуто, а затем сохранено! Спасибо!

//EDIT: что я сейчас делаю (работает, но все еще сталкивается с проблемами памяти с большими изображениями)

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();
11
задан mix3d 4 June 2015 в 20:23
поделиться