안녕하세요 안펍여러분
현재 앱에서 이미지 불러오기 및 크롭 그리고 변환하여 이미지뷰에 띄우기 를 하고 있는데요
갤러리에서 불러오기 그리고 크롭, 이미지뷰에 보여주는것은 되었지만 이걸 임시파일에 저장해
다른 액티비티에서 불러와 변환과정을 거쳐 새 액티비티 내의 이미지뷰에 띄우는 것인데
그게 안되네요.. 하 ㅠㅠ
Bitmap photo = extras2.getParcelable("data");
imgview.setImageBitmap(photo);
// 불러온 사진 임시저장 혹은 인텐트로 넘기는 것이 필요.
ContextWrapper cw = new ContextWrapper(getApplicationContext());
// path to /data/data/yourapp/app_data/imageDir
File directory = cw.getDir("imageDir", Context.MODE_PRIVATE);
// Create imageDir
File mypath = new File(directory,"profile.png");
FileOutputStream fos = null;
try {
fos = new FileOutputStream(mypath);
// Use the compress method on the BitMap object to write image to the OutputStream
photo.compress(Bitmap.CompressFormat.PNG, 100, fos);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
아래는 다른 액티비티에서 임시 파일을 불러올때 쓴 코드입니다.
bitmap_Source 에 이미지가 저장되어지기만 하면 되는데.. 이게 안되네요 ㅠㅠ
String path = "/data/data/ColorIt/app_data/imageDir/profile.png";
try {
File f = new File(path, "profile.png");
bitmap_Source = BitmapFactory.decodeStream(new FileInputStream(f));
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}