public class ImageUtils extends Object
| 构造器和说明 |
|---|
ImageUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static int |
calculateInSampleSize(android.graphics.BitmapFactory.Options options,
int reqWidth,
int reqHeight)
Calculate an inSampleSize for use in a
BitmapFactory.Options object when decoding
bitmaps using the decode* methods from BitmapFactory. |
static android.graphics.Bitmap |
decodeSampledBitmapFromFile(String filename,
int reqWidth,
int reqHeight)
Decode and sample down a bitmap from a file to the requested width and
height.
|
static android.graphics.Bitmap |
decodeUriAsBitmap(android.content.Context ctx,
android.net.Uri uri) |
static android.graphics.Bitmap |
drawableToBitmap(android.graphics.drawable.Drawable drawable) |
static int |
getBitmapSize(android.graphics.Bitmap bitmap) |
static android.graphics.Bitmap |
getRoundedCornerBitmap(android.graphics.Bitmap bitmap,
float roundPx)
获取图片圆角
|
static android.graphics.Bitmap |
rotate(android.graphics.Bitmap b,
int degrees)
旋转图片
|
static boolean |
saveBitmap(File f,
android.graphics.Bitmap bitmap)
保存图片到文件
|
static boolean |
saveBitmap(String path,
android.graphics.Bitmap bitmap) |
static android.graphics.Bitmap |
scaledBitmap(android.graphics.Bitmap src,
int scale)
按比例缩放图片
|
static android.graphics.Bitmap |
scaledBitmap(android.graphics.Bitmap src,
int dstWidth,
int dstHeight)
缩放图片
|
static android.graphics.Bitmap |
toBitmap(android.graphics.drawable.Drawable drawable)
转行Drawable为Bitmap对象
|
static byte[] |
toBytes(android.graphics.Bitmap bitmap)
将图片转换成字节数组
|
static android.graphics.Bitmap |
zoomBitmap(android.graphics.Bitmap bitmap,
int w,
int h) |
public static int getBitmapSize(android.graphics.Bitmap bitmap)
public static android.graphics.Bitmap rotate(android.graphics.Bitmap b,
int degrees)
public static android.graphics.Bitmap decodeSampledBitmapFromFile(String filename, int reqWidth, int reqHeight)
filename - The full path of the file to decodereqWidth - The requested width of the resulting bitmapreqHeight - The requested height of the resulting bitmappublic static int calculateInSampleSize(android.graphics.BitmapFactory.Options options,
int reqWidth,
int reqHeight)
BitmapFactory.Options object when decoding
bitmaps using the decode* methods from BitmapFactory. This
implementation calculates the closest inSampleSize that will result in
the final decoded bitmap having a width and height equal to or larger
than the requested width and height. This implementation does not ensure
a power of 2 is returned for inSampleSize which can be faster when
decoding but results in a larger bitmap which isn't as useful for caching
purposes.options - An options object with out* params already populated (run
through a decode* method with inJustDecodeBounds==truereqWidth - The requested width of the resulting bitmapreqHeight - The requested height of the resulting bitmappublic static boolean saveBitmap(String path, android.graphics.Bitmap bitmap)
public static boolean saveBitmap(File f, android.graphics.Bitmap bitmap)
public static android.graphics.Bitmap decodeUriAsBitmap(android.content.Context ctx,
android.net.Uri uri)
public static android.graphics.Bitmap zoomBitmap(android.graphics.Bitmap bitmap,
int w,
int h)
public static android.graphics.Bitmap drawableToBitmap(android.graphics.drawable.Drawable drawable)
public static android.graphics.Bitmap getRoundedCornerBitmap(android.graphics.Bitmap bitmap,
float roundPx)
bitmap - roundPx - 圆角度数public static android.graphics.Bitmap toBitmap(android.graphics.drawable.Drawable drawable)
drawable - public static android.graphics.Bitmap scaledBitmap(android.graphics.Bitmap src,
int dstWidth,
int dstHeight)
src - 缩放原图dstWidth - 缩放后宽dstHeight - 缩放后高public static android.graphics.Bitmap scaledBitmap(android.graphics.Bitmap src,
int scale)
src - scale - 例如2 就是二分之一public static byte[] toBytes(android.graphics.Bitmap bitmap)
bitmap -