We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
options.inSampleSize = computSampleSize(options, actualOutWidth, actualOutHeight); options.inJustDecodeBounds = false; Bitmap scaledBitmap = null; try { scaledBitmap = BitmapFactory.decodeFile(srcImagePath, options); } catch (OutOfMemoryError e) { e.printStackTrace(); } if (scaledBitmap == null) { return null;//压缩失败 } //生成最终输出的bitmap Bitmap actualOutBitmap = Bitmap.createScaledBitmap(scaledBitmap, (int) actualOutWidth, (int) actualOutHeight, true);
这部分的代码。第一行,是获得压缩比例。而在看了computSampleSize 方法之后发现,我觉得这个方法可以不添加吧。首先,拿到的是四舍五入的int比例,不准确的。而且应该获得宽 高 这两个比例之间最大的那一个。这样才能保证是压缩。 此外,继续下面的代码,获得压缩比例之后根据这个比例压缩了图片获得scaledBitmap ,之后又根据 需要的宽高尺寸 获得 actualOutBitmap 。
The text was updated successfully, but these errors were encountered:
你的api接口在哪里?
Sorry, something went wrong.
No branches or pull requests
options.inSampleSize = computSampleSize(options, actualOutWidth, actualOutHeight);
options.inJustDecodeBounds = false;
Bitmap scaledBitmap = null;
try {
scaledBitmap = BitmapFactory.decodeFile(srcImagePath, options);
} catch (OutOfMemoryError e) {
e.printStackTrace();
}
if (scaledBitmap == null) {
return null;//压缩失败
}
//生成最终输出的bitmap
Bitmap actualOutBitmap = Bitmap.createScaledBitmap(scaledBitmap, (int) actualOutWidth, (int) actualOutHeight, true);
这部分的代码。第一行,是获得压缩比例。而在看了computSampleSize 方法之后发现,我觉得这个方法可以不添加吧。首先,拿到的是四舍五入的int比例,不准确的。而且应该获得宽 高 这两个比例之间最大的那一个。这样才能保证是压缩。 此外,继续下面的代码,获得压缩比例之后根据这个比例压缩了图片获得scaledBitmap ,之后又根据 需要的宽高尺寸 获得 actualOutBitmap 。
The text was updated successfully, but these errors were encountered: