I think I have got it going I am using
- Code: Select all
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, getImageUri());
startActivityForResult(intent, TAKE_PHOTO_CODE);
To take the picture then I am using
private Uri getImageUri() {
Random generator = new Random();
int random = generator.nextInt(50000) + 1;
String capture_title = Integer.toString(random);
String STORAGE_FILE= "FILENAME";
String collected = null;
try {
FileInputStream fis = openFileInput(STORAGE_FILE);
byte[] dataArray = new byte[fis.available()];
while (fis.read(dataArray) != -1) {
collected = new String(dataArray);
}
fis.close();
} catch (FileNotFoundException e) {
Log.e("DATAFILE", "STORAGE_FILEFile Not Found Error");
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
File file = new File(Environment.getExternalStorageDirectory()
+ "/dcim/" + collected, capture_title + ".jpeg");
//I am using this to set a textbox so the user knows the location of the photo
Uri imgUri = Uri.fromFile(file);
holder = imgUri.toString();
editText.setText(holder);
}
return imgUri;
}
I know this will take and store an original photo then one that is resized but that is fine, the photo taking process is working fine for know and the user can use that file as a backup incase of a problem with the resized photo. This is how I am resizing.
- Code: Select all
stringEx = editText.getText().toString();
if (stringEx.startsWith("file://")) {
ten = ten.substring(11);
}
Bitmap mBitmap = BitmapFactory.decodeFile(stringEx );
Display display = getWindowManager().getDefaultDisplay();
int newHeight = display.getHeight();
int newWidth = display.getWidth();
Bitmap resized = Bitmap.createScaledBitmap(mBitmap, newHeight, newWidth, false);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
resized.compress(CompressFormat.JPEG, 0 /*ignored for PNG*/, bos);
byte[] bitmapdata = bos.toByteArray();
StoreByteImage(bitmapdata, 100);
Then I can send it into the StoryByteImage function.
I have to do some playing around with it to get it optimized, but seems to work ok for know. Let me know if you have any input. Thanks for the help also
hce