syyh2006

Bitmap

Bitmap:是android中重要的图像处理工具类,通过bitmap可以对图像进行剪切、旋转、缩放等操作,同时还可以指定格式和压缩质量保存图像文件。

1.对象的构造:查看源码可知,Bitmap内部有一个私有构造器,即不对外提供new实例,从构造器注释以及createBitmap看出,Bitmap仅有nativeCreate实例通过jni的调用完成对象的使用.另外可以通过BitmapFactory jni的方式进行实例化对象的创建.

2.缩放图片:Matrix与Bitmap的使用
  主要思路:创建一个Martix对象,用Bitmap.createBitmap产生一个Bitmap对象,并替换原ImageView的bitmap。


    scaleFactor = 0.9
    int width = Math.round(textureView.getWidth() * scaleFactor);
    int height = Math.round(textureView.getHeight() * scaleFactor);
    Bitmap bitmap = textureView.getBitmap(width, height);//相对于原来缩小了0.1
    // TODO: Figure out why only have to apply the transform in landscape mode
    if (width > height) {
      bitmap =
          Bitmap.createBitmap(
              bitmap,
              0,
              0,
              bitmap.getWidth(),
              bitmap.getHeight(),
              textureView.getTransform(null),
              true);
    }

    blurredImageView.setImageBitmap(bitmap);

posted on 2018-05-18 16:43 syyh2006 阅读(...) 评论(...) 编辑 收藏

分类:

技术点:

Betmap

相关文章:

  • 2021-09-11
  • 2021-09-25
  • 2021-09-26
  • 2021-12-20
  • 2021-12-18
  • 2021-10-30
  • 2021-12-01
  • 2022-01-20
猜你喜欢
  • 2021-04-24
  • 2021-11-27
  • 2021-07-17
  • 2021-06-21
  • 2021-08-26
相关资源
相似解决方案