public final class BitmapUtils extends Object
限定符和类型 | 方法和说明 |
---|---|
static Bitmap |
addProgress(Bitmap src,
Bitmap pro,
int progress)
在src上按progress绘制pro
|
static Bitmap |
addWatermark(Bitmap src,
float left,
float top,
Bitmap img,
int alpha)
添加水印图片
|
static Bitmap |
addWatermark(Bitmap src,
float left,
float top,
String content,
int color,
int size,
int alpha)
添加水印文字
|
static byte[] |
bitmap2Bytes(Bitmap bitmap)
Bitmap to Bytes
|
static Drawable |
bitmap2Drawable(Bitmap bitmap)
bitmap to Drawable
|
static void |
bitmap2File(Bitmap bm,
String path)
bitmap To File
|
static String |
bitmapToString(Bitmap bitmap)
Bitmap转成String
|
static Bitmap |
bytes2Bitmap(byte[] b)
Bytes to Bitmap
|
static Bitmap |
compressImage(Bitmap image,
int quality)
压缩图片按指定精度
|
static Bitmap |
compressImage(Bitmap image,
long maxSize)
压缩图片 按最大图片存储大小
|
static int |
computeSampleSize(BitmapFactory.Options options,
int minSideLength,
int maxNumOfPixels)
计算
|
static Bitmap |
createAlbumIcon(int number,
int textSize,
Bitmap bitmap)
根据数字,创建一张带有数字的图片
|
static Bitmap |
createReflectedImage(Bitmap originalImage)
创建倒影
|
static Bitmap |
createReflectionImageWithOrigin(Bitmap bitmap)
原图添加倒影
|
static Bitmap |
drawable2Bitmap(Drawable drawble)
drawable to Bitmap
|
static int |
getHeight(String filepath)
获取高度
|
static int[] |
getSize(String filepath)
获取宽度,高度
|
static int |
getWidth(String filepath)
获取宽度
|
static String |
imageFileToString(String imagePath)
图片文件转string
|
static Bitmap |
resizeBitmap(Bitmap bitmap,
int maxWidth,
int maxHeight)
重置图片大小
|
static Bitmap |
resizeBitmap(String filepath,
int maxWidth,
int maxHeight)
重置图片文件大小
|
static Bitmap |
roundedCornerBitmap(Bitmap bitmap,
float roundPx)
转为图片
|
static Bitmap |
scale(Bitmap bitmap,
int newWidth,
int newHeight)
缩放图片到新大小(无损)
|
static Bitmap |
scaleFile(String filepath,
int maxWidth,
int maxHeight)
缩放图片按最大宽高(无损)
|
static Bitmap |
screenShot(Activity activity)
截屏
|
static Bitmap |
setAlpha(Bitmap sourceImg,
int number)
设置图片透明度
|
static Bitmap |
stringToBitmap(String string)
String转成Bitmap
|
static Bitmap |
viewScreenshot(View v)
截屏
|
public static Bitmap viewScreenshot(View v)
v
- public static Bitmap addWatermark(Bitmap src, float left, float top, String content, int color, int size, int alpha)
src
- left
- top
- content
- alpha
- public static Bitmap addWatermark(Bitmap src, float left, float top, Bitmap img, int alpha)
src
- left
- top
- img
- alpha
- public static Bitmap addProgress(Bitmap src, Bitmap pro, int progress)
src
- pro
- progress
- public static Bitmap setAlpha(Bitmap sourceImg, int number)
sourceImg
- number
- public static Bitmap roundedCornerBitmap(Bitmap bitmap, float roundPx)
bitmap
- roundPx
- public static Bitmap createReflectionImageWithOrigin(Bitmap bitmap)
bitmap
- public static Bitmap createReflectedImage(Bitmap originalImage)
originalImage
- public static int getWidth(String filepath)
filepath
- public static int getHeight(String filepath)
filepath
- public static int[] getSize(String filepath)
filepath
- public static Bitmap scale(Bitmap bitmap, int newWidth, int newHeight)
bitmap
- newWidth
- newHeight
- public static Bitmap scaleFile(String filepath, int maxWidth, int maxHeight)
filepath
- maxWidth
- maxHeight
- public static Bitmap compressImage(Bitmap image, int quality)
image
- 图片quality
- 精度 推荐大于65public static Bitmap compressImage(Bitmap image, long maxSize)
image
- maxSize
- 最大图片存储大小 (单位b)public static Bitmap resizeBitmap(String filepath, int maxWidth, int maxHeight)
filepath
- maxWidth
- maxHeight
- public static Bitmap resizeBitmap(Bitmap bitmap, int maxWidth, int maxHeight)
bitmap
- maxWidth
- maxHeight
- public static int computeSampleSize(BitmapFactory.Options options, int minSideLength, int maxNumOfPixels)
options
- minSideLength
- maxNumOfPixels
- public static Bitmap createAlbumIcon(int number, int textSize, Bitmap bitmap)
number
- 数字textSize
- 字体大小bitmap
- 图片public static void bitmap2File(Bitmap bm, String path)
bm
- 图片path
- 路径public static byte[] bitmap2Bytes(Bitmap bitmap)
bitmap
- public static Drawable bitmap2Drawable(Bitmap bitmap)
bitmap
- public static Bitmap drawable2Bitmap(Drawable drawble)
drawble
- public static Bitmap bytes2Bitmap(byte[] b)
b
- public static Bitmap screenShot(Activity activity)
activity
- public static String bitmapToString(Bitmap bitmap)
bitmap
- public static String imageFileToString(String imagePath)
imagePath
- public static Bitmap stringToBitmap(String string)
string
-