android 提高图片亮度,android 打开图片,可调节饱和度、色相和亮度
【实例简介】实现打开图片功能【实例截图】【核心代码】此为打开图片功能实现:public class MainActivity extends Activity {//自定义变量private Button selectPhoto;//选择图片private final int IMAGE_OPEN = 1; //打开图片标记@Overrideprotected voi...
【实例简介】实现打开图片功能
【实例截图】
【核心代码】
此为打开图片功能实现:
public class MainActivity extends Activity {
//自定义变量
private Button selectPhoto; //选择图片
private final int IMAGE_OPEN = 1; //打开图片标记
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//选择图片并传递图片路径信息给处理图片活动
selectPhoto = (Button) findViewById(R.id.button1);
selectPhoto.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, IMAGE_OPEN);
}
});
}
//获取图片路径 响应startActivityForResult
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
//打开图片
if(resultCode==RESULT_OK && requestCode==IMAGE_OPEN) {
Uri uri = data.getData();
if (!TextUtils.isEmpty(uri.getAuthority())) {
//查询选择图片
Cursor cursor = getContentResolver().query(
uri,
new String[] { MediaStore.Images.Media.DATA },
null,
null,
null);
//返回 没找到选择图片
if (null == cursor) {
return;
}
//光标移动至开头 获取图片路径
cursor.moveToFirst();
String path = cursor.getString(cursor
.getColumnIndex(MediaStore.Images.Media.DATA));
//Toast.makeText(this, path, Toast.LENGTH_SHORT).show();
//向处理活动传递数据
Intent intent = new Intent(this, ProcessActivity.class); //主活动->处理活动
intent.putExtra("path", path);
startActivity(intent);
} else {
Intent intent = new Intent(this, ProcessActivity.class); //主活动->处理活动
intent.putExtra("path", uri.getPath());
startActivity(intent);
}
} //end if 打开图片
}
}
更多推荐
所有评论(0)