android 图片尺寸格式,Android:使用MediaStore时如何定义图像参数(大小?格式?文件大小).ACTION_IMAGE_CAPTURE...

根据我的经验,你不能通过为这个意图提供参数来设置图像的大小。

如果你会添加这样的东西

intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT,location_of_image_to_save);

,它会返回相机设置的默认尺寸图片。稍后您可以使用此代码更改图像的大小

int width = photo.getWidth();

int height = photo.getHeight();

int newWidth =3000;

int newHeight =3000;

float scaleWidth = ((float) newWidth) / width;// calculate the scale - in this case = 0.4f

float scaleHeight = ((float) newHeight) / height;

// createa matrix for the manipulation

Matrix matrix = new Matrix();

// resize the bit map

matrix.postScale(scaleWidth, scaleHeight);

// rotate the Bitmap

// recreate the new Bitmap

Bitmap.createBitmap(photo, 0, 0,width, height, matrix, true);

Bitmap resizedBitmap = Bitmap.createBitmap(photo, 0, 0, 1000, 1000);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值