我必须将图片上传到服务器。但是,上传后,照片会调整大小。
这就是我在做的事情:
private void clickpic() {
// Check Camera
if (getApplicationContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
// Open default camera
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
// start the image capture Intent
startActivityForResult(intent, 100);
} else {
Toast.makeText(getApplication(), "Nie ma dostępu do aparatu !", Toast.LENGTH_LONG).show();
}
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 100 && resultCode == RESULT_OK) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
selectedImage = data.getData();
photo = (Bitmap) data.getExtras().get("data");
// Cursor to get image uri to display
String[] filePathColumn = {MediaStore.Images.Media.DATA};
Cursor cursor = getContentResolver().query(selectedImage,
filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
picturePath = cursor.getString(columnIndex);
cursor.close();
// photo.compress(Bitmap.CompressFormat.JPEG, 100, stream);
bm = BitmapFactory.decodeFile(picturePath);
imageInByte = stream.toByteArray();
lengthbmp = imageInByte.length;
width = (short) photo.getWidth();
height = (short) photo.getHeight();
showToast(width + " " + height + " " );
imageView.setImageBitmap(photo);
// resizeBm = Image.resizeBitmap(picturePath,Config.resizeWidth , Config.resizeHeight);
}
}