-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImageUtil.java
More file actions
37 lines (33 loc) · 1.09 KB
/
Copy pathImageUtil.java
File metadata and controls
37 lines (33 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package com.yuantuan.ytwebview.utils;
import android.graphics.Bitmap;
import android.graphics.Matrix;
/**
* =============================================================================
* [YTF] (C)2015-2099 Yuantuan Inc.
* Link http://www.ytframework.cn
* =============================================================================
*
* @author Like<[email protected]>
* @created 2016/8/17.
* @description 图片处理工具类
* =============================================================================
*/
public class ImageUtil {
/**
* 缩放图片
* @param bitmap
* @param dst_w
* @param dst_h
* @return
*/
public static Bitmap imageScale(Bitmap bitmap, int dst_w, int dst_h) {
int src_w = bitmap.getWidth();
int src_h = bitmap.getHeight();
float scale_w = ((float) dst_w) / src_w;
float scale_h = ((float) dst_h) / src_h;
Matrix matrix = new Matrix();
matrix.postScale(scale_w, scale_h);
Bitmap dstbmp = Bitmap.createBitmap(bitmap, 0, 0, src_w, src_h, matrix,true);
return dstbmp;
}
}