lmw
2025-04-24 718f31c92e2029d05260810435a2c70cef6e6ce5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
package com.ypx.imagepicker.bean.selectconfig;
 
import android.graphics.Color;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.Size;
 
import com.ypx.imagepicker.widget.cropimage.Info;
 
/**
 * Time: 2019/10/27 18:53
 * Author:ypx
 * Description: 单图剪裁配置类
 */
public class CropConfigParcelable implements Parcelable {
    //充满式剪裁
    public static final int STYLE_FILL = 1;
    //留白式剪裁
    public static final int STYLE_GAP = 2;
    private int cropRatioX = 1;
    private int cropRatioY = 1;
    private boolean isCircle = false;
    private int cropRectMargin = 0;
    private int cropStyle = STYLE_FILL;
    private int cropGapBackgroundColor = Color.BLACK;
 
    private boolean saveInDCIM = false;
 
    // private Size outPutSize;
    private long maxOutPutByte;
    private boolean isLessOriginalByte;
    private Info cropRestoreInfo;
    private boolean isSingleCropCutNeedTop = false;
 
    public boolean isSingleCropCutNeedTop() {
        return isSingleCropCutNeedTop;
    }
 
    public void setSingleCropCutNeedTop(boolean singleCropCutNeedTop) {
        isSingleCropCutNeedTop = singleCropCutNeedTop;
    }
 
    protected CropConfigParcelable() {
 
    }
 
    protected CropConfigParcelable(Parcel in) {
        cropRatioX = in.readInt();
        cropRatioY = in.readInt();
        isCircle = in.readByte() != 0;
        cropRectMargin = in.readInt();
        cropStyle = in.readInt();
        cropGapBackgroundColor = in.readInt();
        saveInDCIM = in.readByte() != 0;
        maxOutPutByte = in.readLong();
        isLessOriginalByte = in.readByte() != 0;
        cropRestoreInfo = in.readParcelable(Info.class.getClassLoader());
        isSingleCropCutNeedTop=in.readByte() != 0;
    }
 
    public static final Creator<CropConfigParcelable> CREATOR = new Creator<CropConfigParcelable>() {
        @Override
        public CropConfigParcelable createFromParcel(Parcel in) {
            return new CropConfigParcelable(in);
        }
 
        @Override
        public CropConfigParcelable[] newArray(int size) {
            return new CropConfigParcelable[size];
        }
    };
 
 
    public long getMaxOutPutByte() {
        return maxOutPutByte;
    }
 
    public void setMaxOutPutByte(long maxOutPutByte) {
        this.maxOutPutByte = maxOutPutByte;
    }
 
    public boolean isLessOriginalByte() {
        return isLessOriginalByte;
    }
 
    public void setLessOriginalByte(boolean lessOriginalByte) {
        isLessOriginalByte = lessOriginalByte;
    }
 
    public Info getCropRestoreInfo() {
        return cropRestoreInfo;
    }
 
    public void setCropRestoreInfo(Info cropRestoreInfo) {
        this.cropRestoreInfo = cropRestoreInfo;
    }
 
    public boolean isSaveInDCIM() {
        return saveInDCIM;
    }
 
    public void saveInDCIM(boolean saveInDCIM) {
        this.saveInDCIM = saveInDCIM;
    }
 
    public int getCropStyle() {
        return cropStyle;
    }
 
    public void setCropStyle(int cropStyle) {
        this.cropStyle = cropStyle;
    }
 
    public int getCropGapBackgroundColor() {
        return cropGapBackgroundColor;
    }
 
    public void setCropGapBackgroundColor(int cropGapBackgroundColor) {
        this.cropGapBackgroundColor = cropGapBackgroundColor;
    }
 
    public boolean isCircle() {
        return isCircle;
    }
 
    public void setCircle(boolean circle) {
        isCircle = circle;
    }
 
 
    public int getCropRectMargin() {
        return cropRectMargin;
    }
 
    public void setCropRectMargin(int cropRectMargin) {
        this.cropRectMargin = cropRectMargin;
    }
 
    public int getCropRatioX() {
        if (isCircle) {
            return 1;
        }
        return cropRatioX;
    }
 
    public void setCropRatio(int x, int y) {
        this.cropRatioX = x;
        this.cropRatioY = y;
    }
 
    public int getCropRatioY() {
        if (isCircle) {
            return 1;
        }
        return cropRatioY;
    }
 
    public boolean isGap() {
        return cropStyle == STYLE_GAP;
    }
 
    public boolean isNeedPng() {
        return isCircle || getCropGapBackgroundColor() == Color.TRANSPARENT;
    }
 
    /**
     * Describe the kinds of special objects contained in this Parcelable
     * instance's marshaled representation. For example, if the object will
     * include a file descriptor in the output of {@link #writeToParcel(Parcel, int)},
     * the return value of this method must include the
     * {@link #CONTENTS_FILE_DESCRIPTOR} bit.
     *
     * @return a bitmask indicating the set of special object types marshaled
     * by this Parcelable object instance.
     */
    @Override
    public int describeContents() {
        return 0;
    }
 
    /**
     * Flatten this object in to a Parcel.
     *
     * @param dest  The Parcel in which the object should be written.
     * @param flags Additional flags about how the object should be written.
     *              May be 0 or {@link #PARCELABLE_WRITE_RETURN_VALUE}.
     */
    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(cropRatioX);
        dest.writeInt(cropRatioY);
        dest.writeByte((byte) (isCircle ? 1 : 0));
        dest.writeInt(cropRectMargin);
        dest.writeInt(cropStyle);
        dest.writeInt(cropGapBackgroundColor);
        dest.writeByte((byte) (saveInDCIM ? 1 : 0));
        dest.writeLong(maxOutPutByte);
        dest.writeByte((byte) (isLessOriginalByte ? 1 : 0));
        dest.writeParcelable(cropRestoreInfo, flags);
        dest.writeByte((byte) (isSingleCropCutNeedTop ? 1 : 0));
    }
}