分享

Bitmap.createBitmap重载方总结 和 Android实现位...

 blankice 2011-12-20
  • 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:要截的图的宽度
  • m:   被应用到像素可选矩阵
  • filter:  true if the source should be filtered. Only applies if the matrix contains more than just translation.
    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.

    • 本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
      转藏 分享 献花(0

      0条评论

      发表

      请遵守用户 评论公约

      类似文章 更多