저는 애플리케이션에서 작업 중이며 사용자가 갤러리에서 이미지를 선택하여 프레임을 적용 할 수 있기를 원합니다. 모바일 갤러리에 성공적으로 액세스했습니다. 이제는 추가 이미지 처리를 위해 선택한 이미지를 저장하는 방법을 알고 싶습니다. 선택한 이미지가 프레임을 적용하는 데 사용됩니다.이미지를 갤러리에서 선택하고 나중에 사용하기 위해 저장하십시오.
0
A
답변
1
여기 있습니다.
Intent intent=new Intent();
intent.setType=("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,"Select Picture"), PICK_IMAGE);
/*Declare PICK_IMAGE globally : private static final int PICK_IMAGE = 1; */
실제 코드이 코드에 여기
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case PICK_IMAGE:
if (resultCode == Activity.RESULT_OK) {
Uri selectedImageUri = data.getData();
try {
// OI FILE Manager
String filemanagerstring = selectedImageUri.getPath();
// MEDIA GALLERY
String selectedImagePath = getPath(selectedImageUri);
if (selectedImagePath != null) {
filePath = selectedImagePath;
} else if (filemanagerstring != null) {
filePath = filemanagerstring;
} else {
Toast.makeText(getApplicationContext(), "Unknown path",
Toast.LENGTH_LONG).show();
Log.e("Bitmap", "Unknown path");
}
if (filePath != null) {
Log.e("file path ","file path "+filePath);
GlobalValues.camefromtw="true";
decodeFile(filePath);
} else {
bitmap = null;
}
} catch (Exception e) {
Toast.makeText(getApplicationContext(), "Internal error",
Toast.LENGTH_LONG).show();
Log.e(e.getClass().getName(), e.getMessage(), e);
}
}
break;protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case PICK_IMAGE:
Log.e("result code","result code"+resultCode+" result "+Activity.RESULT_OK);
if (resultCode == Activity.RESULT_OK) {
Uri selectedImageUri = data.getData();
try {
// OI FILE Manager
String filemanagerstring = selectedImageUri.getPath();
// MEDIA GALLERY
String selectedImagePath = getPath(selectedImageUri);
if (selectedImagePath != null) {
filePath = selectedImagePath;
} else if (filemanagerstring != null) {
filePath = filemanagerstring;
} else {
Toast.makeText(getApplicationContext(), "Unknown path",
Toast.LENGTH_LONG).show();
Log.e("Bitmap", "Unknown path");
}
if (filePath != null) {
decodeFile(filePath);
} else {
bitmap = null;
}
} catch (Exception e) {
Toast.makeText(getApplicationContext(), "Internal error",
Toast.LENGTH_LONG).show();
Log.e(e.getClass().getName(), e.getMessage(), e);
}
}
break;
default:
}
이미지 지금 당신이 그것을 사용할 수있는 파일 경로에 받았다 여기 시작합니다
protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) {
super.onActivityResult(requestCode, resultCode, imageReturnedIntent);
switch(requestCode) {
case REQ_CODE_PICK_IMAGE:
if(resultCode == RESULT_OK){
Uri selectedImage = imageReturnedIntent.getData();
String[] filePathColumn = {MediaStore.Images.Media.DATA};
Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String filePath = cursor.getString(columnIndex);
cursor.close();
Bitmap yourSelectedImage = BitmapFactory.decodeFile(filePath);
//Now do whatever processing you want to do on it.
}
}
}
0
갤러리에서 이미지를 선택하기 위해 다음 코드를 사용하여 나는이 세트를 사용하고있다. ImageView
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);
image.setImageBitmap(bitmap);
}
관련 문제
- 1. jQuery : 나중에 사용하기 위해 언로드 이벤트를 저장하십시오.
- 2. 나중에 사용하기 위해 raw_input을 캡쳐하려고합니다.
- 3. 아이폰에서 나중에 사용하기 위해 이미지 저장
- 4. 나중에 사용하기 위해 이미지를 사용하여 데이터를 저장하는 방법 iphone
- 5. 나중에 ASP.NET에서 사용할 문자열을 저장하십시오.
- 6. 나중에 select 문을 저장하십시오.
- 7. 자바에서 나중에 사용하기 위해 파일 만들기
- 8. 나중에 사용하기 위해 iOS에 객체 저장
- 9. obj-c에서 나중에 사용하기 위해 NSMutableArray를 채우기
- 10. 갤러리에서 이미지를 선택하고 바이트 데이터로 변환하는 방법은 무엇입니까?
- 11. 갤러리에서 이미지를 선택하고 같은 크기의 이미지 뷰로 설정
- 12. 갤러리에서 이미지를 삭제합니다.
- 13. NetBeans에서 나중에 사용하기 위해 정기적으로 사용되는 Grails 명령을 저장하고 있습니까?
- 14. 나중에 수정을 위해 문자열 변수에 DisplayChildren (model)을 저장하십시오.
- 15. 나중에 iPhone에서 재사용하기 위해 체크 된 항목을 테이블보기에 저장하십시오.
- 16. 갤러리에서 이미지를 보내려면
- 17. 메모리 데이터 구조를 나중에 단위 테스트에서 사용하기 위해 보존하는 방법
- 18. 카메라에서 사진을 찍고 갤러리에서 선택하고 이미지보기로 표시
- 19. 나중에 사용하기 위해 AJAX를 통해 가져온 데이터를 저장하는 방법
- 20. Mongodb의 이미지를 Nodejs에 저장하십시오.
- 21. asp.net 웹 사이트에서 이미지를 저장하십시오.
- 22. 여러 이미지를 갤러리에서 서버로 android에 업로드
- 23. 나중에 사용하기 위해 어떻게 든 블록을 저장할 수 있습니까?
- 24. 아이디어 - 부분보기에서 나중에 사용하기 위해 jquery 매개 변수 저장
- 25. 데이터베이스 루프에서 값을 가져와 나중에 사용하기 위해 추가하는 방법
- 26. 나중에 사용하기 위해 날짜를 저장하는 데 어려움을 겪고 있습니다.
- 27. C# 나중에 사용하기 위해 패널을 디자인하는 방법 .. (설정 화면)
- 28. 나중에 사용하기 위해 콘솔 창이나 버퍼의 내용을 저장할 수 있습니까?
- 29. Perl의 익명 sub를 나중에 사용하기 위해 파일에 작성하십시오.
- 30. 나중에 사용하기 위해 <select> 옵션을 저장/생성 하시겠습니까?