![](/img/trans.png)
[英]Android display captured image from Camera in CircleImageView
[英]How to resize image that captured from camera and display on imageview
现在我开发了一个Android应用,需要将图像上传到我的服务器。 但是当我尝试将图像加载到imageview时,它只是显示为空白。 当我将分辨率从1300像素更改为300像素时,图像可以显示在ImageView
。 我的代码我喜欢下面。 请帮忙
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK)
{
viewImage = (ImageView)findViewById(R.id.imgInv);
int width = viewImage.getWidth();
int height = viewImage.getHeight();
Bitmap bitmap;
BitmapFactory.Options bitmapOptions = new BitmapFactory.Options();
bitmapOptions.inJustDecodeBounds = true;
bitmapOptions.inJustDecodeBounds = false;
bitmapOptions.inPreferredConfig = Bitmap.Config.RGB_565;
bitmapOptions.inDither = true;
bitmap = BitmapFactory.decodeFile(f.getAbsolutePath(),bitmapOptions);
viewImage.setImageBitmap(bitmap);
OutputStream outFile = null;
File file = new File(path,String.valueOf(System.currentTimeMillis()) + ".jpg");
imgName = mName + "_" + String.valueOf(System.currentTimeMillis());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 75, baos);
byte[] b = baos.toByteArray();
imgData = Base64.encodeToString(b,Base64.DEFAULT);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.