Here, I am saving the captured image on sdcard from camera. Here, captured image size is greater than 1 MB. I want to reduce this size to nearly 500kb to 600kb before saving to sdcard. How could I do that?
try
{
Bitmap mPhoto;
mPhoto = android.provider.MediaStore.Images.Media.getBitmap(cr, CheckInGallery.mUri);
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
mPhoto.compress(Bitmap.CompressFormat.PNG, 100, bytes);
File direct = new File(Environment.getExternalStorageDirectory() + "/RetailRun");
String mydate = java.text.DateFormat.getDateTimeInstance().format(Calendar.getInstance().getTime());
Toast.makeText(getBaseContext(), "Time :" + mydate, 5000).show();
if(!direct.exists())
{
direct.mkdir();
File file = new File(Environment.getExternalStorageDirectory()+File.separator + "/MyImage/image" + mydate +".jpg");
file.createNewFile();
FileOutputStream fo = new FileOutputStream(file);
fo.write(bytes.toByteArray());
fo.close();
}
else
{
File file = new File(Environment.getExternalStorageDirectory()+File.separator + "/MyImage/image" + mydate +".jpg");
file.createNewFile();
FileOutputStream fo = new FileOutputStream(file);
fo.write(bytes.toByteArray());
fo.close();
}
}
catch (Exception e)
{
Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
}