2011-12-22 20 views
1

私はカメラを使って写真を撮るアプリを持っています。カメラのプレビュー上にオーバーレイが表示されている必要があります。ユーザーは画面の中央にあるサークル内で画像を撮る必要があります。そのため、サーフェイスビューを使用してカメラにPNG画像を配置しました。Androidカメラと表面図Potrait

サーフェイスビューとカメラをpotraitモードにしようとしています。

EDITコードは更新されましたが、現在はエラーLOGTAG cannot be resolvedが発生しています。

public void surfaceCreated(SurfaceHolder holder) { 
    // TODO Auto-generated method stub 

    camera = Camera.open(); 
    try { 
      Camera.Parameters parameters = camera.getParameters(); 
      if (this.getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE) { 
       // This is an undocumented although widely known feature 
       parameters.set("orientation", "portrait"); 
       // For Android 2.2 and above 
       //camera.setDisplayOrientation(90); 
       // Uncomment for Android 2.0 and above 
       //parameters.setRotation(90); 
      } else { 
       // This is an undocumented although widely known feature 
       parameters.set("orientation", "landscape"); 
       // For Android 2.2 and above 
       //camera.setDisplayOrientation(0); 
       // Uncomment for Android 2.0 and above 
       //parameters.setRotation(0); 
      } 
      camera.setParameters(parameters); 
      camera.setPreviewDisplay(holder); 
     } catch (IOException exception) { 
     camera.release(); 
     Log.v(LOGTAG,exception.getMessage()); 
     } 
     camera.startPreview(); 
    } 


public void surfaceDestroyed(SurfaceHolder holder) { 
    // TODO Auto-generated method stub 
    camera.stopPreview(); 
    camera.release(); 
    camera = null; 
    previewing = false; 
} 
} 

答えて

2

使用このコードを...これは

public void surfaceCreated(SurfaceHolder holder) { 
     camera = Camera.open(); 
     try { 
      Camera.Parameters parameters = camera.getParameters(); 
      if (this.getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE) { 
       // This is an undocumented although widely known feature 
       parameters.set("orientation", "portrait"); 
       // For Android 2.2 and above 
       //camera.setDisplayOrientation(90); 
       // Uncomment for Android 2.0 and above 
       //parameters.setRotation(90); 
      } else { 
       // This is an undocumented although widely known feature 
       parameters.set("orientation", "landscape"); 
       // For Android 2.2 and above 
       //camera.setDisplayOrientation(0); 
       // Uncomment for Android 2.0 and above 
       //parameters.setRotation(0); 
      } 
      camera.setParameters(parameters); 
      camera.setPreviewDisplay(holder); 
     } catch (IOException exception) { 
     camera.release(); 
     Log.v(LOGTAG,exception.getMessage()); 
     } 
     camera.startPreview(); 
    } 
+0

...あなたの問題を解決します私は私はintとして、それを追加する必要がないだけで解決できないエラーを取得するために私の質問を更新しましたか? – Matt

+0

Log.v(LOGTAG、exception.getMessage())の行をLog.v( "##########"、exception.getMessage())で置き換えます。 – Sujit

+0

本当にいいです、それは私のためにうまく動作します。ありがとうSujit。 – Hasmukh