|
|
@@ -79,33 +79,42 @@ public class OperationPresenter extends BasePresenter<IOperationView> {
|
|
|
file.getParentFile().mkdirs();
|
|
|
}
|
|
|
|
|
|
- // 开始压缩图片
|
|
|
- boolean saveCropSuccess = ImageUtil.saveBitmapFile(rotatedBitmap, file, multi);
|
|
|
-
|
|
|
- rotatedBitmap.recycle();
|
|
|
- if (saveCropSuccess) {
|
|
|
- File compressedFile = new Compressor(context.getApplicationContext())
|
|
|
- .setQuality(98)
|
|
|
- .setDestinationDirectoryPath(file.getParentFile().getAbsolutePath())
|
|
|
- .compressToFile(file, "cp_" + file.getName());
|
|
|
-
|
|
|
- file.delete();
|
|
|
- // 保存最终截图成功
|
|
|
- // 根据URI获取图片的base64字符串
|
|
|
- photoBase64 = Base64Tool.getBase64FromFilePath(compressedFile.getAbsolutePath());
|
|
|
-
|
|
|
- if (TextUtils.isEmpty(photoBase64)) {
|
|
|
- photoBase64 = Base64Tool.getBase64FromUri(context, uri);
|
|
|
- }
|
|
|
-
|
|
|
- if (TextUtils.isEmpty(photoBase64)) {
|
|
|
- emitter.onError(new Exception("Empty image"));
|
|
|
+ if (multi > 1) {
|
|
|
+ // 开始压缩图片
|
|
|
+ boolean saveCropSuccess = ImageUtil.saveBitmapFile(rotatedBitmap, file, multi);
|
|
|
+
|
|
|
+ rotatedBitmap.recycle();
|
|
|
+ if (saveCropSuccess) {
|
|
|
+ File compressedFile = new Compressor(context.getApplicationContext())
|
|
|
+ .setQuality(99)
|
|
|
+ .setDestinationDirectoryPath(file.getParentFile().getAbsolutePath())
|
|
|
+ .compressToFile(file, "cp_" + file.getName());
|
|
|
+
|
|
|
+ file.delete();
|
|
|
+ // 保存最终截图成功
|
|
|
+ // 根据URI获取图片的base64字符串
|
|
|
+ photoBase64 = Base64Tool.getBase64FromFilePath(compressedFile.getAbsolutePath());
|
|
|
+
|
|
|
+ if (TextUtils.isEmpty(photoBase64)) {
|
|
|
+ photoBase64 = Base64Tool.getBase64FromUri(context, uri);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (TextUtils.isEmpty(photoBase64)) {
|
|
|
+ emitter.onError(new Exception("Empty image"));
|
|
|
+ } else {
|
|
|
+ emitter.onNext(photoBase64);
|
|
|
+ }
|
|
|
} else {
|
|
|
- emitter.onNext(photoBase64);
|
|
|
+ photoBase64 = Base64Tool.bitmap2Base64(rotatedBitmap);
|
|
|
+ if (TextUtils.isEmpty(photoBase64)) {
|
|
|
+ emitter.onError(new Exception("Empty image"));
|
|
|
+ } else {
|
|
|
+ emitter.onNext(photoBase64);
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
- photoBase64 = Base64Tool.getBase64FromUri(context, uri);
|
|
|
-
|
|
|
+ // 不用压缩
|
|
|
+ photoBase64 = Base64Tool.bitmap2Base64(rotatedBitmap);
|
|
|
if (TextUtils.isEmpty(photoBase64)) {
|
|
|
emitter.onError(new Exception("Empty image"));
|
|
|
} else {
|
|
|
@@ -263,7 +272,6 @@ public class OperationPresenter extends BasePresenter<IOperationView> {
|
|
|
} else {
|
|
|
emitter.onError(new Exception("Empty image"));
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
})
|
|
|
/*.filter(base64String -> {
|