Code Monkey home page Code Monkey logo

cropbitmap's Introduction

仿QQ头像裁剪

github

属性 类型 说明
maskColor color 遮罩层颜色(默认#60000000)
borderColor color 裁剪框内部边框颜色(默认白色)
radius dimension 裁剪框圆角(默认为最大值,裁剪框高度的一半)
maxScale float 图片最大放大倍数(默认3)
doubleClickScale float 双击图片放大倍数(默认1.8,最大值不超过maxScale)
<com.github.cropbitmap.LikeQQCropView
    android:id="@+id/likeView"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:background="@color/white"
    />

设置Bitmap

LikeQQCropView likeView=findViewById(R.id.likeView);

//如果传入的bitmap过大,此方法有OOM的可能
likeView.setBitmap(Bitmap bitmap);

//以下方法很安全,做了防止OOM的压缩

/**设置压缩之后的宽和高*/
likeView.setBitmap(多参);

/**[强烈推荐该方法]设置压缩之后的宽度(高度自适应)*/
likeView.setBitmapForWidth(param,屏幕宽度或者view宽度);

/**[推荐该方法]设置压缩之后的高度(宽度自适应)*/
likeView.setBitmapForHeight(多参);

/**设置压缩的缩放倍数(偶数),图片缩小一半传2,缩小4倍传4*/
likeView.setBitmapForScale(多参);

对Bitmap的操作

/**水平翻转*/
likeView.horizontalFlip();

/**垂直翻转*/
likeView.verticalFlip();

/**垂直+水平翻转*/
likeView.verticalAndHorizontalFlip();

/**裁剪*/
likeView.clip();

/**图片位置重置*/
likeView.reset();

/**设置遮罩层*/
likeView.setMaskColor(color);

/**设置裁剪框内部边框颜色*/
likeView.setBorderColor(color);

/**设置裁剪框圆角*/
likeView.setRadius(radius);

/**设置图片最大放大倍数*/
likeView.setMaxScale(3);

/**设置双击图片放大倍数*/
likeView.setDoubleClickScale(1.8);

/**获取裁剪框宽度*/
likeView.getClipWidth();

如果本库对您有帮助,还希望支付宝扫一扫下面二维码,你我同时免费获取奖励金(非常感谢 Y(^-^)Y)

github

最新版本号 Download
implementation 'com.github:MyCropBitmap:版本号看上面'

历史版本说明

  • 1.0.4 解决图片缩放+翻转之后裁剪得到的bitmap宽高过大的问题

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.