我希望我的code保存前调整图像大小,但我不能找到它在谷歌任何东西。 你能帮助我吗?
I want my code to resize the image before saving but I can't find anything about it on Google. Could you help me please ?
这是在code(从Android电子文档):
This is the code (from Android doc) :
private void galleryAddPic() {
Intent mediaScanIntent = new Intent("android.intent.action.MEDIA_SCANNER_SCAN_FILE");
File f = new File(mCurrentPhotoPath);
picturePathForUpload = mCurrentPhotoPath;
Uri contentUri = Uri.fromFile(f);
mediaScanIntent.setData(contentUri);
this.sendBroadcast(mediaScanIntent);
}
在那之后,我必须把它上传到服务器。
After that, I have to upload it to a server.
多谢了。
您可以保存位图图像下面code
You can save Bitmap image following code
Bitmap photo = (Bitmap) "your Bitmap image";
photo = Bitmap.createScaledBitmap(photo, 100, 100, false);
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
photo.compress(Bitmap.CompressFormat.JPEG, 40, bytes);
File f = new File(Environment.getExternalStorageDirectory()
+ File.separator + "Imagename.jpg");
f.createNewFile();
FileOutputStream fo = new FileOutputStream(f);
fo.write(bytes.toByteArray());
fo.close();
上一篇:Convert.ToBoolean和Boolean.Parse不接受0和1不接受、ToBoolean、Convert、Parse
下一篇:android.view.InflateException二进制XML文件中的行#11错误充气类片段片段、错误、文件、view