光环助手V4.1.0-视频上传支持剪辑封面(初步完成,后续细节尚需调整) https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/941
This commit is contained in:
@ -2,7 +2,6 @@ package com.gh.common.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Matrix;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.TypedValue;
|
||||
import android.widget.ImageView;
|
||||
@ -58,24 +57,17 @@ public class CropImageCustom extends RelativeLayout {
|
||||
return mZoomImageView.clip();
|
||||
}
|
||||
|
||||
// 用户头像压缩规则
|
||||
public boolean savePicture(String path) {
|
||||
float limitSize = 900;
|
||||
int quality = 90;
|
||||
Bitmap bitmap = mZoomImageView.clip();
|
||||
File file = new File(path);
|
||||
|
||||
if (bitmap.getHeight() > limitSize || bitmap.getWidth() > limitSize) {
|
||||
Matrix matrix = new Matrix();
|
||||
matrix.setScale(limitSize / bitmap.getWidth(), limitSize / bitmap.getHeight());
|
||||
bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
|
||||
}
|
||||
|
||||
try {
|
||||
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file));
|
||||
bitmap.compress(Bitmap.CompressFormat.WEBP, quality, bos);
|
||||
bos.flush();
|
||||
bos.close();
|
||||
Bitmap clip = mZoomImageView.clip();
|
||||
try {
|
||||
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(new File(path)));
|
||||
clip.compress(Bitmap.CompressFormat.WEBP, 100, bos);
|
||||
bos.flush();
|
||||
bos.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user