简介 目录 评价 推荐
  • 慕龙北星 2021-03-29
    BitmapRegionDecoder用法。
    截图
    0赞 · 0采集
  • 慕龙北星 2021-03-29

    使用BitmapRegionDecoder来加载超大图片。

    截图
    0赞 · 0采集
  • qq_面朝大海_29 2019-03-06

    如截图所示

    截图
    0赞 · 0采集
  • xzhang76 2019-01-07

    超大图片

    1.使用BitmapRegionDecoder.decodeRegion()来实现

    public Bitmap decodeRegion(Rect rect, BitmapFactory.Options options);

    2.通常的做法是

    (1)定义一个View来显示这张图,在onMeasure()中创建一个和View一样大小的Rect,用来作为decodeRegion()的参数

    int width = getMeasuredWidth();
    int height = getMeasuredHeight();//View宽和高
    
    int imgWidth = mImgWidth;
    int imgHeight = mImgHeight; //图片宽和高, 通过BitmapFactory.decodeFile(..., options)可以拿到,当然options.inJustDecodeBounds = true
    
    //获取rect的左右上下边界, 默认是显示图片的中心区域
    mRect.left = imgWidth/2 - width/2;
    mRect.top = imgHeight/2 - height/2;
    mRect.right = imgWidth/2 + width/2;
    mRect.bottom = imgHeight/2 + height/2;

    (2)在自定义View的onDraw()方法中将decodeRegion()得到的bitmap进行绘制到View上

    (3)这个View还需要实现OnGestureListener接口,实现自己的move()函数,其实主要是改变这个Rect。然后调用invalidate()从decodeRegion(rect, ...)中拿到新的bitmap(可能只是一个小区域),再进行draw(bitmap, ...);

    截图
    1赞 · 0采集
数据加载中...
开始学习 免费