Android examples for android.graphics:Image Load Save
get Crop Image Intent
import java.io.File; import java.io.IOException; import android.content.Intent; import android.graphics.Bitmap; import android.net.Uri; import android.os.Build; import android.os.Environment; import android.provider.MediaStore; import android.util.Log; public class Main { public static final String OUT_FILE = Environment.getExternalStorageDirectory() + "/out.jpg"; public static Intent getCropImageIntent(Uri photoUri, int aspectX, int aspectY, int outputX, int outputY) { Intent intent = null;//from w w w . ja v a 2s. c o m if (Integer.parseInt(Build.VERSION.SDK) > 18) { intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI); } else { intent = new Intent("com.android.camera.action.CROP"); } intent.setDataAndType(photoUri, "image/*"); intent.putExtra("crop", "true"); intent.putExtra("aspectX", aspectX); intent.putExtra("aspectY", aspectY); intent.putExtra("outputX", outputX); intent.putExtra("outputY", outputY); intent.putExtra("scale", true); if (isMotorlaMobile()) { intent.putExtra("return-data", true); } else { File outFile = new File(OUT_FILE); try { if (outFile.exists()) { outFile.delete(); } outFile.getParentFile().mkdirs(); outFile.createNewFile(); } catch (IOException ex) { Log.e("io", ex.getMessage()); } intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(outFile)); intent.putExtra("return-data", false); intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString()); intent.putExtra("noFaceDetection", false); } return intent; } public static boolean isMotorlaMobile() { return false; } }