wsy858 / android-headimage-cliper Goto Github PK
View Code? Open in Web Editor NEW头像上传图片裁剪,实现仿QQ、微信两种效果
头像上传图片裁剪,实现仿QQ、微信两种效果
PT,机型是mate9,裁剪画面一片漆黑
具体到getRealFilePathFromUri方法里返回的data为null.导致到剪裁图片的界面为空白的.一片
手机小米8
问题:图片裁切的是圆形,返回保存之后就变成正方形了.
setLayer既然是一个耗费性能的操作,其实我们在获得中间完全透明区域的时候,关闭掉硬件加速就可以了
**### setLayerType(View.LAYER_TYPE_SOFTWARE, null);**
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
/* int LAYER_FLAGS = Canvas.MATRIX_SAVE_FLAG | Canvas.CLIP_SAVE_FLAG
| Canvas.HAS_ALPHA_LAYER_SAVE_FLAG | Canvas.FULL_COLOR_LAYER_SAVE_FLAG
| Canvas.CLIP_TO_LAYER_SAVE_FLAG;
canvas.saveLayer(0, 0, this.getWidth(), this.getHeight(), null, LAYER_FLAGS);*/ 注释掉
//设置背景
canvas.drawColor(Color.parseColor("#a8000000"));
paint.setXfermode(xfermode);
//绘制圆形裁剪框
if (clipType == ClipType.CIRCLE) {
//中间的透明的圆
canvas.drawCircle(this.getWidth() / 2, this.getHeight() / 2, clipRadiusWidth, paint);
//白色的圆边框
canvas.drawCircle(this.getWidth() / 2, this.getHeight() / 2, clipRadiusWidth, borderPaint);
} else if (clipType == ClipType.RECTANGLE) { //绘制矩形裁剪框
//绘制中间的矩形
canvas.drawRect(mHorizontalPadding, this.getHeight() / 2 - clipWidth / 2,
this.getWidth() - mHorizontalPadding, this.getHeight() / 2 + clipWidth / 2, paint);
//绘制白色的矩形边框
canvas.drawRect(mHorizontalPadding, this.getHeight() / 2 - clipWidth / 2,
this.getWidth() - mHorizontalPadding, this.getHeight() / 2 + clipWidth / 2, borderPaint);
}
//出栈,恢复到之前的图层,意味着新建的图层会被删除,新建图层上的内容会被绘制到canvas (or the previous layer)
//canvas.restore(); 注释掉
}
拜读了您的代码,发现您没有适配7.0拍照的权限
这样,剪切界面的圆圈只是虚拟的,假的,没有以圆圈大小为剪切范围。
用andorid studio Monitors工具,重复几次操作,内存疯涨,导致在部分手机会出现直接闪退的的情况
在裁剪界面 回到桌面再进入app ,这个时候裁剪区域超过相册边缘 ,导致裁剪范围不正确
找到问题根源了。
public static Bitmap decodeSampledBitmap(String filePath, int reqWidth,
int reqHeight) {
、、、、
// Bitmap.Config.RGB_565 改成ARGB_xxx就行了。
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
、、、、、、、、
return BitmapFactory.decodeFile(filePath, options);
}
如题
从相册选择图片,在系统弹出的文件管理系统中选择横向图片,未进行放大时移动照片,出现抖动的问题(注:小米5sPlus,7.0系统)。在项目代码(evan/wang/view/ClipViewLayout.java:161)中,
//高的最小缩放比
minScale = rect.height() / (float) bitmap.getHeight();
if (scale < minScale) {
scale = minScale;
}
这种图片,应该属于scale < minScale的情况。
未研究透代码,冒昧试用以下方法(修改scale = minScale1.1f ;),不会出现抖动问题,不知究竟是何原因。
//高的最小缩放比
minScale = rect.height() / (float) bitmap.getHeight();
if (scale < minScale) {
scale = minScale1.1f ;
}
作者有注意到 双指缩放最小时候,图片会产生抖动?
索尼不知道 出啥幺蛾子了
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.