Skip to content

Commit 8d48446

Browse files
committed
see 12/17 log
1 parent e448f92 commit 8d48446

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

utilcode/README-CN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ getImageType : 获取图片类型
349349
compressByScale : 按缩放压缩
350350
compressByQuality : 按质量压缩
351351
compressBySampleSize : 按采样大小压缩
352+
getSize : 获取图片尺寸
352353
```
353354

354355
* ### 意图相关 -> [IntentUtils.java][intent.java]

utilcode/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ getImageType
349349
compressByScale
350350
compressByQuality
351351
compressBySampleSize
352+
getSize
352353
```
353354

354355
* ### About Intent -> [IntentUtils.java][intent.java]

utilcode/lib/src/main/java/com/blankj/utilcode/util/ImageUtils.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1872,6 +1872,30 @@ public static Bitmap compressBySampleSize(final Bitmap src,
18721872
return BitmapFactory.decodeByteArray(bytes, 0, bytes.length, options);
18731873
}
18741874

1875+
/**
1876+
* Return the size of bitmap.
1877+
*
1878+
* @param filePath The path of file.
1879+
* @return the size of bitmap
1880+
*/
1881+
public static int[] getSize(String filePath) {
1882+
return getSize(getFileByPath(filePath));
1883+
}
1884+
1885+
/**
1886+
* Return the size of bitmap.
1887+
*
1888+
* @param file The file.
1889+
* @return the size of bitmap
1890+
*/
1891+
public static int[] getSize(File file) {
1892+
if (file == null) return new int[]{0, 0};
1893+
BitmapFactory.Options opts = new BitmapFactory.Options();
1894+
opts.inJustDecodeBounds = true;
1895+
BitmapFactory.decodeFile(file.getAbsolutePath(), opts);
1896+
return new int[]{opts.outWidth, opts.outHeight};
1897+
}
1898+
18751899
/**
18761900
* Return the sample size.
18771901
*

0 commit comments

Comments
 (0)