/////////////////////////////////////////////////////////////////////////////////
///// below code is used to save the bitmap into sdcard ////////////////////
/////////////////////////////////////////////////////////////////////////////////
String extStorageDirectory = Environment.getExternalStorageDirectory().toString();;
OutputStream outStream = null;
File file = new File(extStorageDirectory, "SlectImage.PNG");
try {
outStream = new FileOutputStream(file);
picturebitmap.compress(Bitmap.CompressFormat.PNG, 100, outStream);
outStream.flush();
outStream.close();
Toast.makeText(PhotoManipulation.this, "Saved", Toast.LENGTH_LONG).show();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Toast.makeText(PhotoManipulation.this, e.toString(), Toast.LENGTH_LONG).show();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Toast.makeText(PhotoManipulation.this, e.toString(), Toast.LENGTH_LONG).show();
}
/////////////////////////////////////////////////////////////////////////////////
///// below code is used to get the saved image and set to imageview ////////////////////
/////////////////////////////////////////////////////////////////////////////////
final String imageInSD = "/sdcard/SlectImage.PNG";
Bitmap bitmap = BitmapFactory.decodeFile(imageInSD);
ImageView myImageView = (ImageView)findViewById(R.id.imageview);
myImageView.setImageBitmap(bitmap);
///// below code is used to save the bitmap into sdcard ////////////////////
/////////////////////////////////////////////////////////////////////////////////
String extStorageDirectory = Environment.getExternalStorageDirectory().toString();;
OutputStream outStream = null;
File file = new File(extStorageDirectory, "SlectImage.PNG");
try {
outStream = new FileOutputStream(file);
picturebitmap.compress(Bitmap.CompressFormat.PNG, 100, outStream);
outStream.flush();
outStream.close();
Toast.makeText(PhotoManipulation.this, "Saved", Toast.LENGTH_LONG).show();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Toast.makeText(PhotoManipulation.this, e.toString(), Toast.LENGTH_LONG).show();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Toast.makeText(PhotoManipulation.this, e.toString(), Toast.LENGTH_LONG).show();
}
/////////////////////////////////////////////////////////////////////////////////
///// below code is used to get the saved image and set to imageview ////////////////////
/////////////////////////////////////////////////////////////////////////////////
final String imageInSD = "/sdcard/SlectImage.PNG";
Bitmap bitmap = BitmapFactory.decodeFile(imageInSD);
ImageView myImageView = (ImageView)findViewById(R.id.imageview);
myImageView.setImageBitmap(bitmap);
No comments:
Post a Comment