Comments (3)
追问,我也是想问这个问题,如何始终保持正方形剪切
from imaging.
这个功能和微信一样,没有支持正方形,以及制定比例的裁剪功能
from imaging.
我研究了下源码可以这样设置比例,如下还未验证希望高手指导一下是否正确
1.创建config配置文件
package me.minetsh.imaging;
public class IMGConfig {
private static IMGConfig mInstance;
private boolean isSave;
public CropMode cropMode = CropMode.SQUARE;
private IMGConfig() {
}
public static IMGConfig getInstance() {
if (mInstance == null) {
synchronized (IMGConfig.class) {
if (mInstance == null) {
mInstance = new IMGConfig();
}
}
}
return mInstance;
}
public void setCropMode(CropMode mode) {
this.cropMode = mode;
}
public enum CropMode {
RATIO_4_3(1),
RATIO_3_4(2),
SQUARE(3),
RATIO_16_9(4),
RATIO_9_16(5),
FREE(6);
private final int ID;
CropMode(final int id) {
this.ID = id;
}
public int getId() {
return ID;
}
}
}
2.在IMGClipWindow.java的 private void reset(float clipWidth, float clipHeight)方法下添加如下代码(更多比例自行添加)
/**
* 重置裁剪
*/
private void reset(float clipWidth, float clipHeight) {
setResetting(true);
//处理裁剪模式
if (IMGConfig.getInstance().cropMode == IMGConfig.CropMode.FREE) {
//自由模式
mFrame.set(0, 0, clipWidth, clipHeight);
} else if (IMGConfig.getInstance().cropMode == IMGConfig.CropMode.SQUARE) {
//正方形
mFrame.set(0, 0, Math.min(clipWidth, clipHeight), Math.min(clipWidth, clipHeight));
}
IMGUtils.fitCenter(mWinFrame, mFrame, CLIP_MARGIN);
mTargetFrame.set(mFrame);
}
3.在IMGimage.java的onTouchDown方法中添加如下代码或修改为如下
public void onTouchDown(float x, float y) {
isSteady = false;
moveToBackground(mForeSticker);
if (mMode == IMGMode.CLIP && IMGConfig.getInstance().cropMode == IMGConfig.CropMode.FREE) {
//只有裁剪模式下并且自由裁剪才可以拖动
mAnchor = mClipWin.getAnchor(x, y);
}
}
4.使用裁剪功能前调用IMGConfig设置cropMode即可
5.本人还未验证是否会产生其他BUG 只是提供一下我的思路
from imaging.
Related Issues (20)
- 将已经编辑的照片保存本地之后再反复编辑之后的图片,在oppo r9上会模糊不知道什么情况
- 7.0以上会闪退 HOT 1
- 涂鸦模式时,双指缩放后左上角会出现一个红点 HOT 6
- 一些手机选择照片后不展示,黑屏 HOT 5
- 有iOS版本的吗 HOT 2
- 资源释放清除问题 HOT 1
- 请问贴片边界问题怎么解决 HOT 1
- android Q不支持
- 裁切后画笔区域判断错误
- 单独是用IMGView出现黑屏 HOT 1
- 初始化图片有点倾斜,该怎么解决
- IMGStickerView.java 170行 Child测量需要调用getChildMeasureSpec HOT 1
- 能否抽成一个库上传jcenter
- 如何控制缩放比例,如果无限制放大下去,最终保存会崩溃
- licence许可 HOT 1
- 请问一下 文字可以拖拽出图片范围怎么改?
- 你好,有英文版本的界面吗
- 不支持7.0 HOT 1
- 跳转不给去
- 是否可以加入橡皮擦功能? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from imaging.