Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Saved images are low quality
    text
    copied!<p>I'm taking pictures through the following code and saving to SD card, but the pictures that it produces are such low quality and really bitty even with 100% quality. Maybe bitmap.compress isn't the right way to go (or bitmap at all?!)</p> <p>Heres my code:</p> <pre><code>public class TakePhoto extends Activity { ImageView iv; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_take_photo); iv = (ImageView) findViewById(R.id.imageView1); Button b = (Button) findViewById(R.id.button1); b.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(intent, 0); } }); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // TODO Auto-generated method stub super.onActivityResult(requestCode, resultCode, data); Bitmap bm = (Bitmap) data.getExtras().get("data"); Random generator = new Random(); String randFileName = String.valueOf (generator.nextInt(965) + 32); String both = "/mnt/extSdCard/DirectEnquiries/"+ randFileName + ".jpg"; File imageFile = new File(both); writeBitmapToMemory(imageFile, bm); iv.setImageBitmap(bm); } public void writeBitmapToMemory(File file, Bitmap bitmap) { FileOutputStream fos; try { Log.e("Tom", "Starting take stream"); fos = new FileOutputStream(file); Log.e("Tom", "Got stream"); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos); Log.e("Tom", "Saved Image"); fos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload