AndBase开发框架  1.6
 全部  命名空间 文件 函数 变量 枚举值 
静态 Public 成员函数 | 静态 Public 属性 | 静态 Private 成员函数 | 所有成员列表
com.ab.util.AbImageUtil类 参考

静态 Public 成员函数

static Bitmap getBitmap (String url, int type, int desiredWidth, int desiredHeight)
 
static Bitmap getBitmap (File file)
 
static Bitmap getScaleBitmap (File file, int desiredWidth, int desiredHeight)
 
static Bitmap getScaleBitmap (Bitmap bitmap, int desiredWidth, int desiredHeight)
 
static Bitmap getScaleBitmap (Bitmap bitmap, float scale)
 
static Bitmap getCutBitmap (File file, int desiredWidth, int desiredHeight)
 
static Bitmap getCutBitmap (Bitmap bitmap, int desiredWidth, int desiredHeight)
 
static float[] getBitmapSize (File file)
 
static Bitmap drawableToBitmap (Drawable drawable)
 
static Drawable bitmapToDrawable (Bitmap bitmap)
 
static TransitionDrawable bitmapToTransitionDrawable (Bitmap bitmap)
 
static TransitionDrawable drawableToTransitionDrawable (Drawable drawable)
 
static byte[] bitmap2Bytes (Bitmap bitmap, Bitmap.CompressFormat mCompressFormat, final boolean needRecycle)
 
static int getByteCount (Bitmap bitmap, Bitmap.CompressFormat mCompressFormat)
 
static Bitmap bytes2Bimap (byte[] b)
 
static Bitmap imageView2Bitmap (ImageView view)
 
static Drawable view2Drawable (View view)
 
static Bitmap view2Bitmap (View view)
 
static byte[] view2Bytes (View view, Bitmap.CompressFormat compressFormat)
 
static Bitmap rotateBitmap (Bitmap bitmap, float degrees)
 
static Bitmap rotateBitmapTranslate (Bitmap bitmap, float degrees)
 
static Bitmap toRoundBitmap (Bitmap bitmap)
 
static Bitmap toReflectionBitmap (Bitmap bitmap)
 
static void releaseBitmap (Bitmap bitmap)
 
static void releaseBitmapArray (Bitmap[] bitmaps)
 
static String getHashCode (Bitmap bitmap)
 
static String getDCTHashCode (Bitmap bitmap)
 
static int[] getColorHistogram (Bitmap bitmap)
 
static int hammingDistance (String sourceHashCode, String hashCode)
 
static void main (String[] args)
 

静态 Public 属性

static final int CUTIMG = 0
 
static final int SCALEIMG = 1
 
static final int ORIGINALIMG = 2
 
static final int MAX_WIDTH = 4096/2
 
static final int MAX_HEIGHT = 4096/2
 

静态 Private 成员函数

static float getMinScale (int srcWidth, int srcHeight, int desiredWidth, int desiredHeight)
 
static int[] resizeToMaxSize (int srcWidth, int srcHeight, int desiredWidth, int desiredHeight)
 
static boolean checkBitmap (Bitmap bitmap)
 
static boolean checkSize (int desiredWidth, int desiredHeight)
 
static int rgbToGray (int pixels)
 

详细描述

© 2012 amsoft.cn 名称:AbImageUtil.java 描述:图片处理类.

作者
还如一梦中
版本
v1.0
日期
:2013-01-17 下午11:52:13

成员函数说明

static byte [] com.ab.util.AbImageUtil.bitmap2Bytes ( Bitmap  bitmap,
Bitmap.CompressFormat  mCompressFormat,
final boolean  needRecycle 
)
inlinestatic

将Bitmap转换为byte[].

参数
bitmapthe bitmap
mCompressFormat图片格式 Bitmap.CompressFormat.JPEG,CompressFormat.PNG
needRecycle是否需要回收
返回
byte[] 图片的byte[]
static Drawable com.ab.util.AbImageUtil.bitmapToDrawable ( Bitmap  bitmap)
inlinestatic

Bitmap对象转换Drawable对象.

参数
bitmap要转化的Bitmap对象
返回
Drawable 转化完成的Drawable对象
static TransitionDrawable com.ab.util.AbImageUtil.bitmapToTransitionDrawable ( Bitmap  bitmap)
inlinestatic

Bitmap对象转换TransitionDrawable对象.

参数
bitmap要转化的Bitmap对象 imageView.setImageDrawable(td); td.startTransition(200);
返回
Drawable 转化完成的Drawable对象
static Bitmap com.ab.util.AbImageUtil.bytes2Bimap ( byte[]  b)
inlinestatic

描述:将byte[]转换为Bitmap.

参数
b图片格式的byte[]数组
返回
bitmap 得到的Bitmap
static boolean com.ab.util.AbImageUtil.checkBitmap ( Bitmap  bitmap)
inlinestaticprivate
static boolean com.ab.util.AbImageUtil.checkSize ( int  desiredWidth,
int  desiredHeight 
)
inlinestaticprivate
static Bitmap com.ab.util.AbImageUtil.drawableToBitmap ( Drawable  drawable)
inlinestatic

Drawable转Bitmap.

参数
drawable要转化的Drawable
返回
Bitmap
static TransitionDrawable com.ab.util.AbImageUtil.drawableToTransitionDrawable ( Drawable  drawable)
inlinestatic

Drawable对象转换TransitionDrawable对象.

参数
drawable要转化的Drawable对象 imageView.setImageDrawable(td); td.startTransition(200);
返回
Drawable 转化完成的Drawable对象
static Bitmap com.ab.util.AbImageUtil.getBitmap ( String  url,
int  type,
int  desiredWidth,
int  desiredHeight 
)
inlinestatic

直接获取互联网上的图片.

参数
url要下载文件的网络地址
type图片的处理类型(剪切或者缩放到指定大小,参考AbConstant类)
desiredWidth新图片的宽
desiredHeight新图片的高
返回
Bitmap 新图片
static Bitmap com.ab.util.AbImageUtil.getBitmap ( File  file)
inlinestatic

描述:获取原图.

参数
fileFile对象
返回
Bitmap 图片
static float [] com.ab.util.AbImageUtil.getBitmapSize ( File  file)
inlinestatic

描述:获取图片尺寸

参数
fileFile对象
返回
Bitmap 新图片
static int com.ab.util.AbImageUtil.getByteCount ( Bitmap  bitmap,
Bitmap.CompressFormat  mCompressFormat 
)
inlinestatic

获取Bitmap大小.

参数
bitmapthe bitmap
mCompressFormat图片格式 Bitmap.CompressFormat.JPEG,CompressFormat.PNG
返回
图片的大小
static int [] com.ab.util.AbImageUtil.getColorHistogram ( Bitmap  bitmap)
inlinestatic

描述:图像的特征值颜色分布 将颜色分4个区,0,1,2,3 区组合共64组,计算每个像素点属于哪个区.

参数
bitmapthe bitmap
返回
the color histogram
static Bitmap com.ab.util.AbImageUtil.getCutBitmap ( File  file,
int  desiredWidth,
int  desiredHeight 
)
inlinestatic

描述:裁剪图片.

参数
fileFile对象
desiredWidth新图片的宽
desiredHeight新图片的高
返回
Bitmap 新图片
static Bitmap com.ab.util.AbImageUtil.getCutBitmap ( Bitmap  bitmap,
int  desiredWidth,
int  desiredHeight 
)
inlinestatic

描述:裁剪图片.

参数
bitmapthe bitmap
desiredWidth新图片的宽
desiredHeight新图片的高
返回
Bitmap 新图片
static String com.ab.util.AbImageUtil.getDCTHashCode ( Bitmap  bitmap)
inlinestatic

描述:图像的特征值余弦相似度.

参数
bitmapthe bitmap
返回
the DCT hash code
static String com.ab.util.AbImageUtil.getHashCode ( Bitmap  bitmap)
inlinestatic

描述:简单的图像的特征值,用于缩略图找原图比较好.

参数
bitmapthe bitmap
返回
the hash code
static float com.ab.util.AbImageUtil.getMinScale ( int  srcWidth,
int  srcHeight,
int  desiredWidth,
int  desiredHeight 
)
inlinestaticprivate
static Bitmap com.ab.util.AbImageUtil.getScaleBitmap ( File  file,
int  desiredWidth,
int  desiredHeight 
)
inlinestatic

描述:缩放图片.压缩

参数
fileFile对象
desiredWidth新图片的宽
desiredHeight新图片的高
返回
Bitmap 新图片
static Bitmap com.ab.util.AbImageUtil.getScaleBitmap ( Bitmap  bitmap,
int  desiredWidth,
int  desiredHeight 
)
inlinestatic

描述:缩放图片,不压缩的缩放.

参数
bitmapthe bitmap
desiredWidth新图片的宽
desiredHeight新图片的高
返回
Bitmap 新图片
static Bitmap com.ab.util.AbImageUtil.getScaleBitmap ( Bitmap  bitmap,
float  scale 
)
inlinestatic

描述:根据等比例缩放图片.

参数
bitmapthe bitmap
scale比例
返回
Bitmap 新图片
static int com.ab.util.AbImageUtil.hammingDistance ( String  sourceHashCode,
String  hashCode 
)
inlinestatic

计算"汉明距离"(Hamming distance)。 如果不相同的数据位不超过5,就说明两张图片很相似;如果大于10,就说明这是两张不同的图片。.

参数
sourceHashCode源hashCode
hashCode与之比较的hashCode
返回
the int
static Bitmap com.ab.util.AbImageUtil.imageView2Bitmap ( ImageView  view)
inlinestatic

将ImageView转换为Bitmap.

参数
view要转换为bitmap的View
返回
byte[] 图片的byte[]
static void com.ab.util.AbImageUtil.main ( String[]  args)
inlinestatic

The main method.

参数
argsthe arguments
static void com.ab.util.AbImageUtil.releaseBitmap ( Bitmap  bitmap)
inlinestatic

释放Bitmap对象.

参数
bitmap要释放的Bitmap
static void com.ab.util.AbImageUtil.releaseBitmapArray ( Bitmap[]  bitmaps)
inlinestatic

释放Bitmap数组.

参数
bitmaps要释放的Bitmap数组
static int [] com.ab.util.AbImageUtil.resizeToMaxSize ( int  srcWidth,
int  srcHeight,
int  desiredWidth,
int  desiredHeight 
)
inlinestaticprivate
static int com.ab.util.AbImageUtil.rgbToGray ( int  pixels)
inlinestaticprivate

灰度值计算.

参数
pixels像素
返回
int 灰度值
static Bitmap com.ab.util.AbImageUtil.rotateBitmap ( Bitmap  bitmap,
float  degrees 
)
inlinestatic

描述:旋转Bitmap为一定的角度.

参数
bitmapthe bitmap
degreesthe degrees
返回
the bitmap
static Bitmap com.ab.util.AbImageUtil.rotateBitmapTranslate ( Bitmap  bitmap,
float  degrees 
)
inlinestatic

描述:旋转Bitmap为一定的角度并四周暗化处理.

参数
bitmapthe bitmap
degreesthe degrees
返回
the bitmap
static Bitmap com.ab.util.AbImageUtil.toReflectionBitmap ( Bitmap  bitmap)
inlinestatic

转换图片转换成镜面效果的图片.

参数
bitmap传入Bitmap对象
返回
the bitmap
static Bitmap com.ab.util.AbImageUtil.toRoundBitmap ( Bitmap  bitmap)
inlinestatic

转换图片转换成圆形.

参数
bitmap传入Bitmap对象
返回
the bitmap
static Bitmap com.ab.util.AbImageUtil.view2Bitmap ( View  view)
inlinestatic

将View转换为Bitmap.需要最上层布局为Linearlayout

参数
view要转换为bitmap的View
返回
byte[] 图片的byte[]
static byte [] com.ab.util.AbImageUtil.view2Bytes ( View  view,
Bitmap.CompressFormat  compressFormat 
)
inlinestatic

将View转换为byte[].

参数
view要转换为byte[]的View
compressFormatthe compress format
返回
byte[] View图片的byte[]
static Drawable com.ab.util.AbImageUtil.view2Drawable ( View  view)
inlinestatic

将View转换为Drawable.需要最上层布局为Linearlayout

参数
view要转换为Drawable的View
返回
BitmapDrawable Drawable

类成员变量说明

final int com.ab.util.AbImageUtil.CUTIMG = 0
static

图片处理:裁剪.

final int com.ab.util.AbImageUtil.MAX_HEIGHT = 4096/2
static

图片最大高度.

final int com.ab.util.AbImageUtil.MAX_WIDTH = 4096/2
static

图片最大宽度.

final int com.ab.util.AbImageUtil.ORIGINALIMG = 2
static

图片处理:不处理.

final int com.ab.util.AbImageUtil.SCALEIMG = 1
static

图片处理:缩放.


该类的文档由以下文件生成: