开发者

Android Camera in Portrait on SurfaceView and save the Snapshot

my api is 2.2,so i used camera.setDisplayOrientation(90) to make the preview is Portrait,this work very well,but when i save the pic to sd,the pic is horizontal not Portrait.when i used :

@Override
    protected Bitmap doInBackground(String... params) {

        int w = bmp.getWidth();
        int h = bmp.getHeight();
        // Setting post rotate to 90
        Matrix mtx = new Matrix();
        mtx.postRotate(90);
        // Rotating Bitmap
        Bitmap rotatedBMP = Bitmap.createBitmap(bmp, 0, 0, w, h, mtx, true);
        bmp.recycle();
        return rotatedBMP;
    }

    @Override
    protected void onPostExecute(Bitmap result) {
        // TODO Auto-generated method stub
      开发者_C百科  super.onPostExecute(result);
        dialog.dismiss();

        ivNewPhoto.setImageBitmap(result);
        resultPath = ConstValue.MY_ALBUM_DIR + "/" + System.currentTimeMillis() + ".jpg";
        ImageFile.writePhotoJpg(result), resultPath);
        previewView.setVisibility(View.VISIBLE);
    }

bmp is the Snapshot pic but i have mistakes:

Activity com.android.SuperPictureSearch.photo.PhotoActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@43abb200 that was originally added here

can you tell me how to save the pic is Portrait,thank you


 public void onPictureTaken(byte[] data, Camera camera) {

          Bitmap mutableBitmap = null;
          BitmapFactory.Options options = new BitmapFactory.Options();
          Bitmap  bm= BitmapFactory.decodeByteArray(data, 0, data.length, options);
           mutableBitmap =Bitmap.createScaledBitmap( bm , h, w,true);
             bm.recycle();
                Matrix matri = new Matrix();
                matri.postRotate(90);

                Bitmap  mBitmap = Bitmap.createBitmap(mutableBitmap, 0, 0, mutableBitmap.getWidth(), mutableBitmap.getHeight(), matri, true);
                mutableBitmap.recycle();

because the pic is too big form camera,so i size it

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜