Bitmap.createBitmap函数有6个重载方法

  • 1.public static Bitmap createBitmap (Bitmap src)
    从原位图src复制出一个新的位图,和原始位图相同

  • 2.public static Bitmap createBitmap (int[] colors, int width, int height, Bitmap.Config config) 
    这个函数根据颜色数组来创建位图,注意:颜色数组的长度>=width*height

    此函数创建位图的过程可以简单概括为为:更加width和height创建空位图,然后用指定的颜色数组colors来从左到右从上至下一次填充颜色。config是一个枚举,可以用它来指定位图“质量”。

  • 3.public static Bitmap createBitmap (int[] colors, int offset, int stride, int width, int height, Bitmap.Config config)
    此方法与2类似,但我还不明白offset和stride的作用。

  • 4.public static Bitmap createBitmap (Bitmap source, int x, int y, int width, int height, Matrix m, boolean filter)
    从原始位图剪切图像,这是一种高级的方式。可以用Matrix(矩阵)来实现旋转等高级方式截图
    参数说明:
      Bitmap source:要从中截图的原始位图
      int x:起始x坐标
      int y:起始y坐标
    int width:要截的图的宽度
    int height:要截的图的宽度
    Bitmap.Config  config:一个枚举类型的配置,可以定义截到的新位图的质量
    返回值:返回一个剪切好的Bitmap
  • 5.public static Bitmap createBitmap (int width, int height, Bitmap.Config config)
    根据参数创建新位图

  • 6.public static Bitmap createBitmap (Bitmap source, int x, int y, int width, int height) 

    简单的剪切图像的方法,可以参考上面的4.

  • Bitmap.Config ALPHA_8   
    Bitmap.Config ARGB_4444   
    Bitmap.Config ARGB_8888   
    Bitmap.Config RGB_565  

      A  R  G  B
    透明度 红色 绿色 蓝色

    Bitmap.Config ARGB_4444 16 每个像素 占四位   
    Bitmap.Config ARGB_8888 32 每个像素 占八位  
    Bitmap.Config RGB_565 16 R占5位 G占6位 B占5位 没有透明度(A)

    一般情况下我们都是用argb888 但是无可厚非 它也相对的很占内存
    因为一个像素32位 8位一个字节 如果是800*480的图片的话自己算 估计有1M多了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值