Rabbit-R1/android (non root)/java/sources/com/google/zxing/datamatrix/encoder/DefaultPlacement.java

182 lines
5.2 KiB
Java
Raw Normal View History

2024-05-21 21:08:36 +00:00
package com.google.zxing.datamatrix.encoder;
import java.util.Arrays;
/* loaded from: classes3.dex */
public class DefaultPlacement {
private final byte[] bits;
private final CharSequence codewords;
private final int numcols;
private final int numrows;
final byte[] getBits() {
return this.bits;
}
final int getNumcols() {
return this.numcols;
}
final int getNumrows() {
return this.numrows;
}
public DefaultPlacement(CharSequence charSequence, int i, int i2) {
this.codewords = charSequence;
this.numcols = i;
this.numrows = i2;
byte[] bArr = new byte[i * i2];
this.bits = bArr;
Arrays.fill(bArr, (byte) -1);
}
public final boolean getBit(int i, int i2) {
return this.bits[(i2 * this.numcols) + i] == 1;
}
private void setBit(int i, int i2, boolean z) {
this.bits[(i2 * this.numcols) + i] = z ? (byte) 1 : (byte) 0;
}
private boolean noBit(int i, int i2) {
return this.bits[(i2 * this.numcols) + i] < 0;
}
public final void place() {
int i;
int i2;
int i3 = 0;
int i4 = 0;
int i5 = 4;
while (true) {
if (i5 == this.numrows && i3 == 0) {
corner1(i4);
i4++;
}
if (i5 == this.numrows - 2 && i3 == 0 && this.numcols % 4 != 0) {
corner2(i4);
i4++;
}
if (i5 == this.numrows - 2 && i3 == 0 && this.numcols % 8 == 4) {
corner3(i4);
i4++;
}
if (i5 == this.numrows + 4 && i3 == 2 && this.numcols % 8 == 0) {
corner4(i4);
i4++;
}
while (true) {
if (i5 < this.numrows && i3 >= 0 && noBit(i3, i5)) {
utah(i5, i3, i4);
i4++;
}
int i6 = i5 - 2;
int i7 = i3 + 2;
if (i6 < 0 || i7 >= this.numcols) {
break;
}
i5 = i6;
i3 = i7;
}
int i8 = i5 - 1;
int i9 = i3 + 5;
while (true) {
if (i8 >= 0 && i9 < this.numcols && noBit(i9, i8)) {
utah(i8, i9, i4);
i4++;
}
int i10 = i8 + 2;
int i11 = i9 - 2;
i = this.numrows;
if (i10 >= i || i11 < 0) {
break;
}
i8 = i10;
i9 = i11;
}
i5 = i8 + 5;
i3 = i9 - 1;
if (i5 >= i && i3 >= (i2 = this.numcols)) {
break;
}
}
if (noBit(i2 - 1, i - 1)) {
setBit(this.numcols - 1, this.numrows - 1, true);
setBit(this.numcols - 2, this.numrows - 2, true);
}
}
private void module(int i, int i2, int i3, int i4) {
if (i < 0) {
int i5 = this.numrows;
i += i5;
i2 += 4 - ((i5 + 4) % 8);
}
if (i2 < 0) {
int i6 = this.numcols;
i2 += i6;
i += 4 - ((i6 + 4) % 8);
}
setBit(i2, i, (this.codewords.charAt(i3) & (1 << (8 - i4))) != 0);
}
private void utah(int i, int i2, int i3) {
int i4 = i - 2;
int i5 = i2 - 2;
module(i4, i5, i3, 1);
int i6 = i2 - 1;
module(i4, i6, i3, 2);
int i7 = i - 1;
module(i7, i5, i3, 3);
module(i7, i6, i3, 4);
module(i7, i2, i3, 5);
module(i, i5, i3, 6);
module(i, i6, i3, 7);
module(i, i2, i3, 8);
}
private void corner1(int i) {
module(this.numrows - 1, 0, i, 1);
module(this.numrows - 1, 1, i, 2);
module(this.numrows - 1, 2, i, 3);
module(0, this.numcols - 2, i, 4);
module(0, this.numcols - 1, i, 5);
module(1, this.numcols - 1, i, 6);
module(2, this.numcols - 1, i, 7);
module(3, this.numcols - 1, i, 8);
}
private void corner2(int i) {
module(this.numrows - 3, 0, i, 1);
module(this.numrows - 2, 0, i, 2);
module(this.numrows - 1, 0, i, 3);
module(0, this.numcols - 4, i, 4);
module(0, this.numcols - 3, i, 5);
module(0, this.numcols - 2, i, 6);
module(0, this.numcols - 1, i, 7);
module(1, this.numcols - 1, i, 8);
}
private void corner3(int i) {
module(this.numrows - 3, 0, i, 1);
module(this.numrows - 2, 0, i, 2);
module(this.numrows - 1, 0, i, 3);
module(0, this.numcols - 2, i, 4);
module(0, this.numcols - 1, i, 5);
module(1, this.numcols - 1, i, 6);
module(2, this.numcols - 1, i, 7);
module(3, this.numcols - 1, i, 8);
}
private void corner4(int i) {
module(this.numrows - 1, 0, i, 1);
module(this.numrows - 1, this.numcols - 1, i, 2);
module(0, this.numcols - 3, i, 3);
module(0, this.numcols - 2, i, 4);
module(0, this.numcols - 1, i, 5);
module(1, this.numcols - 3, i, 6);
module(1, this.numcols - 2, i, 7);
module(1, this.numcols - 1, i, 8);
}
}