2015-11-10 57 views
0

我的應用程序在圖片上疊加了相機預覽,並且在捕捉時保存了疊加層。 但是,當我使用前置攝像頭拍攝時,它會顯示相機預覽的鏡像。 現在我想在使用前置攝像頭時翻轉圖像,但是當我捕捉疊加圖像時,「標記」不會與捕獲的圖像一起保存。 我在做什麼錯?在畫布上繪製翻轉的圖像

     { 

         Bitmap cameraBitmap = BitmapFactory.decodeByteArray(data, 0, data.length); 
        int wid = cameraBitmap.getWidth(); 
        int hgt = cameraBitmap.getHeight(); 
        // Toast.makeText(getApplicationContext(), wid+""+hgt, Toast.LENGTH_SHORT).show(); 
         Bitmap newImage = Bitmap.createBitmap(wid, hgt, Bitmap.Config.ARGB_8888); 
         Canvas canvas = new Canvas(newImage); 
         if (currentCameraId == Camera.CameraInfo.CAMERA_FACING_BACK) 
          { 
         canvas.drawBitmap(cameraBitmap, 0f, 0f, null); 
          } 
         else 
         { 
          canvas.drawBitmap(cameraBitmap, 0f, 0f, null); 
         // newImage = flip(newImage); 
          Matrix matrix = new Matrix(); 
          matrix.preScale(-1.0f, 1.0f); 
          // unknown type 
          // return transformed image 
          newImage= Bitmap.createBitmap(newImage, 0, 0, newImage.getWidth(), newImage.getHeight(), matrix, true); 
          canvas.drawBitmap(cameraBitmap, 0f, 0f, null); 
         } 
        Drawable drawable getResources().getDrawable(R.drawable.mark); 
         drawable.setBounds(20, 30, drawable.getIntrinsicWidth()+20, drawable.getIntrinsicHeight()+30); 
        drawable.draw(canvas); 

回答