我正在尝试调整图像大小,但是当调整大小以获得低分辨率图像时。有没有其他使用java代码在andorid中调整图像大小的解决方案。
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 4;
Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath(), options);
int h = 300;
int w = 300;
Bitmap scaled = Bitmap.createScaledBitmap(myBitmap, h, w, true);
String root = Environment.getExternalStorageDirectory()
.toString();
File myDir = new File(root + "/upload_images");
myDir.mkdirs();
String fname = null;
if (rname == null) {
fname = "Image.jpg";
} else {
fname = rname + ".jpg";
Log.i("log_tag", "File anem::" + fname);
}
file = new File(myDir, fname);
Log.i("log_tag", "" + file);
if (file.exists())
file.delete();
try {
FileOutputStream out = new FileOutputStream(file);
scaled.compress(Bitmap.CompressFormat.JPEG, 90, out);
out.flush();
out.close();