我工作的一个应用程序,其中我需要挑选 SD卡
的图像,并显示在图像视图。现在,我希望用户减少/通过点击一个按钮,增加它的宽度,然后将其重新保存到SD卡上。
I am working on an application, in which I need to pick an image from sd card
and show it in image view. Now I want the user to decrease/increase its width by clicking a button and then save it back to the sd card.
我也做了影像撷取,并显示它的UI。但无法找到如何调整it.Can请人建议我如何去实现它。
I have done the image picking and showing it on ui. But unable to find how to resize it.Can anyone please suggest me how to achieve it.
就在昨天,我已经做到了这一点。
Just yesterday i have done this
File dir=Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM);
Bitmap b= BitmapFactory.decodeFile(PATH_ORIGINAL_IMAGE);
Bitmap out = Bitmap.createScaledBitmap(b, 320, 480, false);
File file = new File(dir, "resize.png");
FileOutputStream fOut;
try {
fOut = new FileOutputStream(file);
out.compress(Bitmap.CompressFormat.PNG, 100, fOut);
fOut.flush();
fOut.close();
b.recycle();
out.recycle();
} catch (Exception e) {}
另外别忘了回收你的位图
:这将节省内存
您还可以得到新创建的文件字符串的路径:的新路径= file.getAbsolutePath();
You can also get path of new created file String: newPath=file.getAbsolutePath();