2011-08-02 63 views
7

我有一個Android應用程序,我使用的是安卓相機以拍攝照片。並且在拼湊一些後,我設法讓我的照片在我想要的位置以及我的想法。最後的問題是圖像的質量。增加用安卓相機拍攝的照片的質量/清晰度/亮度

當我的預覽開始時,一切都看起來非常清晰和優雅,但是在拍照並顯示最終結果後,圖像看起來並不好看。

這裏是我的surfaceChanged()方法看起來像,在那裏我設置一些參數:

public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) { 
     Log.e(TAG, "surfaceChanged"); 
     if (mPreviewRunning) { 
      mCamera.stopPreview(); 
     } 

     Camera.Parameters p = mCamera.getParameters(); 
     List<Size> sizes = p.getSupportedPictureSizes(); 

System.out.println("Lista de parametrii este urmatoarea:"+sizes); 
     Size size = sizes.get(7); 
     p.setPictureSize(size.width,size.height); 
     mCamera.setParameters(p); 
     try { 
      mCamera.setPreviewDisplay(holder); 
     } catch (IOException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } 
     mCamera.startPreview(); 
     mPreviewRunning = true; 
    } 

Coudl有人告訴什麼是增加我的photo.Thanks質量的方法!

編輯:

activity A在拍攝照片時,我使用的是捆綁到圖像發送到另一個activity B在那裏我將它存儲在SDCARD。這裏就是我如何做到這一點:

Activity A

Camera.PictureCallback mPictureCallback = new Camera.PictureCallback(){ 
     public void onPictureTaken(byte[] imageData, Camera c) { 

      if (imageData != null) { 

       Intent mIntent = new Intent(); 
       Bundle b = new Bundle(); 
       b.putByteArray("imageData", imageData); 
       Intent i = new Intent(mContext,ImageDisplayActivity.class); 
       i.putExtras(b); 
       startActivity(i); 

       setResult(FOTO_MODE, mIntent); 
       finish(); 

      } 
     } 
    }; 
activity B

Bundle extras = getIntent().getExtras(); 
     BitmapFactory.Options options=new BitmapFactory.Options(); 
     options.inSampleSize = 5; 
     byte[] imageData = extras.getByteArray("imageData"); 
     Bitmap myImage = BitmapFactory.decodeByteArray(imageData , 0, imageData.length,options); 

     Matrix mat=new Matrix(); 
     mat.postRotate(90); 
     bitmapResult = Bitmap.createBitmap(myImage, 0, 0, myImage.getWidth(),myImage.getHeight(), mat, true); 

     Canvas c = new Canvas(bitmapResult); 
     drawTextImage(bitmapResult); 

我收到我把它放在一個位圖中的圖片,我將它旋轉並在方法drawTextImage()上繪製文本。 這一切後我店使用這種上sdcardbitmapResult

public static boolean StoreByteImage(Context mContext, Bitmap bitmap, int quality, String expName) { 


     FileOutputStream fileOutputStream = null; 
     String extStorageDirectory=Environment.getExternalStorageDirectory().toString(); 
     File myNewFolder = new File(extStorageDirectory + newFolder); 
     if(myNewFolder.mkdirs()) 
     { 
     myNewFolder.mkdir(); 
     } 
     try {  

      //fileOutputStream = new FileOutputStream(sdImageMainDirectory.toString() +"/image.jpg"); 
      fileOutputStream = new FileOutputStream(myNewFolder +"/"+expName+".jpg"); 
      BufferedOutputStream bos = new BufferedOutputStream(fileOutputStream); 

      bitmap.compress(CompressFormat.JPEG, quality, bos); 

      bos.flush(); 
      bos.close(); 

     } catch (FileNotFoundException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } catch (IOException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } 

     return true; 
    } 

我ussually這樣稱呼它:StoreByteImage(getBaseContext(),bitmapResult,100,String.valueOf(value)); 感謝

+0

但它看起來,因爲當我使用相機拍攝一張照片,應用程序之外......只是爲了好玩disaster.There必須的東西,畫面看起來華麗! – adrian

+0

我希望我會找到解決方案的原因否則....我不知道我要做什麼! – adrian

+0

你的意思是什麼?解析度?明晰?亮度?對比?色彩均衡?有很多事情可以說明照片的質量。 –

回答

0

我有這個問題,因爲自動對焦被禁用。

嘗試增加這個權限在你的Android清單:

<uses-feature android:name="android.hardware.camera.autofocus" /> 
+0

我有它:)....但照片仍不清楚! – adrian

+0

我也有同樣的問題,但仍然沒有得到正確的結果。 –

相關問題