2013-04-24 2 views
0

사용자가 카메라로 사진을 찍어 지정된 폴더에 저장할 수있는 앱을 만들려고합니다. 그러나 imageView에서 PNG 파일로 변환 할 때 품질이 크게 떨어집니다. 카메라에서 이미지를 이미지로 저장할 때 화질이 저하됩니다.

나는 품질을 보장 ​​할 코드의이 비트를 사용하는 나는 낮은 숫자 100에서 품질을 변경할 때

bmap.compress(Bitmap.CompressFormat.PNG, 100, output); 

그러나 심지어 내가 어떤 차이를 볼 수 없습니다 높게 유지 것이라고 생각했다.

if (requestCode == cameraData && resultCode == RESULT_OK 
      && null != data) { 
     Bitmap photo = (Bitmap) data.getExtras().get("data"); 

     ImageView imageView = (ImageView) findViewById(R.id.imgView); 
     imageView.setImageBitmap(photo); 

     // convert imageview to bitm 
     imageView.buildDrawingCache(); 
     final Bitmap bmap = imageView.getDrawingCache(); 

     addIt.setOnClickListener(new View.OnClickListener() { 

      @Override 
      public void onClick(View arg0) { 
       // TODO Auto-generated method stub 

       OutputStream output; 

       // Find the SD Card path 
       File filepath = Environment.getExternalStorageDirectory(); 

       // Create a new folder AndroidBegin in SD Card 
       File dir = new File(filepath.getAbsolutePath() 
         + "/filepath1/"); 
       dir.mkdirs(); 

       // Create a name for the saved image 
       File file = new File(dir, "image.png"); 

       // Notify the user on successful save 
       Toast.makeText(Images.this, "Image Saved to SD Card", 
         Toast.LENGTH_SHORT).show(); 
       try { 

        // Image starts saving 
        output = new FileOutputStream(file); 

        // Compress into png format image from 0% - 100%, using 
        // 100% for this tutorial 
        bmap.compress(Bitmap.CompressFormat.PNG, 100, output); 

        output.flush(); 
        output.close(); 

        Intent myIntent = new Intent(Images.this, 
          MyPreferencesActivity.class); 
        startActivity(myIntent); 
       } 

       // Catch exceptions 
       catch (Exception e) { 
        // TODO Auto-generated catch block 
        e.printStackTrace(); 
       } 
      } 
+1

PNG는 무손실이며 "품질"설정은 해당 형식에 적용되지 않습니다. – leonbloy

+0

이 답변을 확인할 수 있습니다. 그 일은 훌륭합니다. http://stackoverflow.com/questions/10377783/low-picture-image-quality-when-capture-from-camera –

답변

관련 문제