【发布时间】:2015-11-30 21:34:14
【问题描述】:
我编写了这段代码,它用相机拍照,然后将其转换为 jpeg 文件并作为 ParseFile 上传到 Parse.com。
问题是图片非常小(153 x 204 像素)而且质量非常低。
我需要图片质量至少为 5 MP,并将其裁剪为 300x300 像素。
这是我现在使用的代码。
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_picture);
img = (ImageView) findViewById(R.id.imgV);
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
byte[] image_byte_array;
ParseObject post_object = new ParseObject("Gallery");
Bundle extras = data.getExtras();
Bitmap image = (Bitmap) extras.get("data");
ByteArrayOutputStream stream = new ByteArrayOutputStream();
image.compress(Bitmap.CompressFormat.JPEG, 100, stream);
image_byte_array = stream.toByteArray();
ParseFile picture_file = new ParseFile("Picture.jpg", image_byte_array);
picture_file.saveInBackground();
post_object.put("photo", picture_file);
post_object.saveInBackground();
}
提前致谢。
【问题讨论】:
标签: android image android-camera crop image-quality