2012-08-07 85 views

回答

1

1)這裏有一個教程如何使用Android的相機: tutorial

2)覆蓋了位圖的攝像機圖像,你必須: - 創建一個位圖 - 創建一個畫布參考該位圖 - 將照片從相機繪製到畫布。 (由於您在使用畫布時未創建此位圖的副本,所做更改將應用​​於您創建的位圖)。

3)要保存一個位圖,你可以用這個方法我說:

/** 
    * <b><i>public void writeBitmapToMemory(String filename, Bitmap bitmap)</i></b> 
    * <br> 
    * Since: API 1 
    * <br> 
    * <br> 
    * Write a bitmap to the phone's internal storage. 
    * 
    * @param filename 
    * The name of the file you wish to write to. 
    * 
    *  
    */ 

    public void writeBitmapToMemory(String filename, Bitmap bitmap) { 
     FileOutputStream fos; 
     // Use the compress method on the Bitmap object to write image to the OutputStream 
     try { 
      fos = game.openFileOutput(filename, Context.MODE_PRIVATE); 
      // Writing the bitmap to the output stream 
      bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos); 
      fos.close(); 
      // this.gameEngineLog.d(classTAG, "Bitmap successfully written: " + filename); 
     } 
     catch (FileNotFoundException e) { 
      e.printStackTrace(); 
      // this.gameEngineLog.d(classTAG, "Bitmap couldn't be written: " + filename); 

     } 
     catch (IOException e) { 
      e.printStackTrace(); 
      this.gameEngineLog.d(classTAG, "Bitmap couldn't be written: " + filename); 

     } 

    }