Android 如何将相机拍摄的图像添加到现有图像
我是android初学者开发者。我想得到一些关于我的问题的提示。 问题:如何在现有图像的某一点上添加图像。有很多应用程序的瀑布效应。他们从相机上拍摄照片,并将照片附加到现有的瀑布图像上 请向我推荐任何好的库或程序试试这个Android 如何将相机拍摄的图像添加到现有图像,android,image-processing,Android,Image Processing,我是android初学者开发者。我想得到一些关于我的问题的提示。 问题:如何在现有图像的某一点上添加图像。有很多应用程序的瀑布效应。他们从相机上拍摄照片,并将照片附加到现有的瀑布图像上 请向我推荐任何好的库或程序试试这个 Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(intent, REQUEST_CAMERA); @Override
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, REQUEST_CAMERA);
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PICK_IMAGE && resultCode == getActivity().RESULT_OK && null != data) {
Uri selectedImageUri = data.getData();
String selectedImagePath = getRealPathFromURIForGallery(selectedImageUri);
decodeFile(selectedImagePath);
}
public String getRealPathFromURIForGallery(Uri uri) {
if (uri == null) {
return null;
}
String[] projection = {MediaStore.Images.Media.DATA};
Cursor cursor = getActivity().getContentResolver().query(uri, projection, null, null, null);
if (cursor != null) {
int column_index = cursor
.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
return uri.getPath();
}
public void decodeFile(String filePath) {
// Decode image size
BitmapFactory.Options o = new BitmapFactory.Options();
o.inJustDecodeBounds = true;
BitmapFactory.decodeFile(filePath, o);
// The new size we want to scale to
final int REQUIRED_SIZE = 1024;
// Find the correct scale value. It should be the power of 2.
int width_tmp = o.outWidth, height_tmp = o.outHeight;
int scale = 1;
while (true) {
if (width_tmp < REQUIRED_SIZE && height_tmp < REQUIRED_SIZE)
break;
width_tmp /= 2;
height_tmp /= 2;
scale *= 2;
}
// Decode with inSampleSize
BitmapFactory.Options o2 = new BitmapFactory.Options();
o2.inSampleSize = scale;
bitmap = BitmapFactory.decodeFile(filePath, o2);
profileImage.setImageBitmap(bitmap);
}
Intent Intent=新意图(MediaStore.ACTION\u IMAGE\u CAPTURE);
startActivityForResult(意图、请求和摄像头);
@凌驾
ActivityResult上的公共void(int请求代码、int结果代码、意图数据){
super.onActivityResult(请求代码、结果代码、数据);
if(requestCode==PICK_IMAGE&&resultCode==getActivity().RESULT_OK&&null!=data){
Uri selectedImageUri=data.getData();
字符串selectedImagePath=getRealPathFromURIForGallery(selectedImageUri);
解码文件(选择图像路径);
}
公共字符串getRealPathFromURIForGallery(Uri){
if(uri==null){
返回null;
}
字符串[]投影={MediaStore.Images.Media.DATA};
Cursor Cursor=getActivity().getContentResolver().query(uri、投影、null、null、null);
如果(光标!=null){
int column_index=游标
.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
返回cursor.getString(列索引);
}
返回uri.getPath();
}
公共文件(字符串文件路径){
//解码图像大小
BitmapFactory.Options o=新的BitmapFactory.Options();
o、 inJustDecodeBounds=true;
解码文件(文件路径,o);
//我们要扩展到的新尺寸
所需的最终int_SIZE=1024;
//找到正确的刻度值。它应该是2的幂。
内部宽度=o.向外宽度,高度=o.向外高度;
int标度=1;
while(true){
如果(宽度\u tmp<要求的\u尺寸和高度\u tmp<要求的\u尺寸)
打破
宽度_tmp/=2;
高度_tmp/=2;
比例*=2;
}
//用inSampleSize解码
BitmapFactory.Options o2=新的BitmapFactory.Options();
o2.inSampleSize=刻度;
位图=BitmapFactory.decodeFile(文件路径,o2);
profileImage.setImageBitmap(位图);
}
此代码仅显示pic图像并在图像视图中显示,而不是在另一个右侧嵌入一张图片?