i have a camera take picture method, it will intent to camera like this :
public void takePicture() {
InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
cameraHelper = new CameraHelper();
cameraHelper.initialize(this, this.getApplicationContext(), CAPTURED_IMAGE_PATH);
Intent imageIntent = cameraHelper.dispatchTakePictureIntent(CameraHelper.ACTION_TAKE_PHOTO_B);
startActivityForResult(imageIntent, CameraHelper.ACTION_TAKE_PHOTO_B);
}
after user finish take and save photo, i try to get the result and resize & compress it. this is my on acitivty result :
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CameraHelper.ACTION_TAKE_PHOTO_B || requestCode == CameraHelper.ACTION_TAKE_PHOTO_S) {
File f = cameraHelper.onActivityResult(requestCode, resultCode, data);
if (f != null) {
try{
Log.i("PHOTO", "Start to resize");
Bitmap b = BitmapFactory.decodeStream(getAssets().open(f.getAbsolutePath()));
Log.i("PHOTO", "orginal width : "+b.getWidth()+", original height : "+b.getHeight());
ByteArrayOutputStream out = new ByteArrayOutputStream();
Bitmap resized = Bitmap.createScaledBitmap(b, b.getWidth()/2, b.getHeight()/2, true);
Log.i("PHOTO", "Resize width : "+resized.getWidth()+", Resize height : "+resized.getHeight());
resized.compress(Bitmap.CompressFormat.JPEG, 100, out);
Bitmap decoded = BitmapFactory.decodeStream(new ByteArrayInputStream(out.toByteArray()));
Log.i("PHOTO", "Compress width : "+decoded.getWidth()+", Compress height : "+decoded.getHeight());
}catch(Exception e){
Log.i("PHOTO", e.toString());
}
} else {
Toast.makeText(this, "F IS NULL", Toast.LENGTH_SHORT).show();
}
}
}
but :( there is error , and this is the log :
07-30 13:57:01.149: I/PHOTO(28841): Start to resize
07-30 13:57:01.154: I/PHOTO(28841): java.io.FileNotFoundException: file://storage/sdcard0/Pictures/imotax/capture/spop/IMG_20130730_135655_98370721.jpg
please help me.. to fix this and also it can resize and compress the image. thanks guys