Here is my code
This is the way I am compressing bitmap, but image quality totally gone.Please suggest answers to save image without losing quality.
Note: (Image was captured from camera)
public String saveImage(Bitmap myBitmap) {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
myBitmap.compress(Bitmap.CompressFormat.PNG, 100, bytes);
File wallpaperDirectory = new File(Environment.getExternalStorageDirectory() + "/"+Environment.DIRECTORY_PICTURES);
Log.e("wallpaperDirectory","wallpaperDirectory"+wallpaperDirectory);
if (!wallpaperDirectory.exists()) { // have the object build the directory structure, if needed.
wallpaperDirectory.mkdirs();
}
try {
String timeStamp = new SimpleDateFormat("yyyyMMdd").format(new Date());
File f = new File(wallpaperDirectory, "IMG_"+currentJob.getJob_number()+"_"+timeStamp+ ".png");
f.createNewFile();
FileOutputStream fo = new FileOutputStream(f);
fo.write(bytes.toByteArray());
MediaScannerConnection.scanFile(mContext,
new String[]{f.getPath()},
new String[]{"image/png"}, null);
fo.close();
Log.e("TAG", "File Saved::--->" + f.getAbsolutePath());
return f.getAbsolutePath();
} catch (IOException e1) {
e1.printStackTrace();
Log.e("hiii","hiiicrashh");
}
return "";
}