"Android Code Snippet"
Save bitmap as file to sdcard in android:
private String saveBitmapAsImageInSdcard(Bitmap bm) {
String pathis = "";
Bitmap cstemp = null;
cstemp = Bitmap.createBitmap(bm.getWidth(), bm.getHeight(), Bitmap.Config.ARGB_8888);
Canvas comboImage = new Canvas(cstemp);
comboImage.drawBitmap(bm,0, 0,null);
String tmpImg = "filename.png";
OutputStream os = null;
try {
pathis = TEMPPATH + tmpImg;
os = new FileOutputStream(pathis);
cstemp.compress(CompressFormat.PNG, 100, os);
}
catch (IOException e) {
Log.e("combineImages", "problem combining images", e);
}
return pathis;
}
Save bitmap as file to sdcard in android:
private String saveBitmapAsImageInSdcard(Bitmap bm) {
String pathis = "";
Bitmap cstemp = null;
cstemp = Bitmap.createBitmap(bm.getWidth(), bm.getHeight(), Bitmap.Config.ARGB_8888);
Canvas comboImage = new Canvas(cstemp);
comboImage.drawBitmap(bm,0, 0,null);
String tmpImg = "filename.png";
OutputStream os = null;
try {
pathis = TEMPPATH + tmpImg;
os = new FileOutputStream(pathis);
cstemp.compress(CompressFormat.PNG, 100, os);
}
catch (IOException e) {
Log.e("combineImages", "problem combining images", e);
}
return pathis;
}
No comments:
Post a Comment