本文整理汇总了Java中com.google.zxing.common.reedsolomon.ReedSolomonException类的典型用法代码示例。如果您正苦于以下问题:Java ReedSolomonException类的具体用法?Java ReedSolomonException怎么用?Java ReedSolomonException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ReedSolomonException类属于com.google.zxing.common.reedsolomon包,在下文中一共展示了ReedSolomonException类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: correctErrors
import com.google.zxing.common.reedsolomon.ReedSolomonException; //导入依赖的package包/类
/**
* <p>Given data and error-correction codewords received, possibly corrupted by errors, attempts to
* correct the errors in-place using Reed-Solomon error correction.</p>
*
* @param codewordBytes data and error correction codewords
* @param numDataCodewords number of codewords that are data bytes
* @throws ChecksumException if error correction fails
*/
private void correctErrors(byte[] codewordBytes, int numDataCodewords) throws ChecksumException {
int numCodewords = codewordBytes.length;
// First read into an array of ints
int[] codewordsInts = new int[numCodewords];
for (int i = 0; i < numCodewords; i++) {
codewordsInts[i] = codewordBytes[i] & 0xFF;
}
int numECCodewords = codewordBytes.length - numDataCodewords;
try {
rsDecoder.decode(codewordsInts, numECCodewords);
} catch (ReedSolomonException ignored) {
throw ChecksumException.getChecksumInstance();
}
// Copy back into array of bytes -- only need to worry about the bytes that were data
// We don't care about errors in the error-correction codewords
for (int i = 0; i < numDataCodewords; i++) {
codewordBytes[i] = (byte) codewordsInts[i];
}
}
示例2: correctErrors
import com.google.zxing.common.reedsolomon.ReedSolomonException; //导入依赖的package包/类
/**
* <p>Given data and error-correction codewords received, possibly corrupted by errors, attempts to
* correct the errors in-place using Reed-Solomon error correction.</p>
*
* @param codewordBytes data and error correction codewords
* @param numDataCodewords number of codewords that are data bytes
* @throws ChecksumException if error correction fails
*/
private void correctErrors(byte[] codewordBytes, int numDataCodewords) throws ChecksumException {
int numCodewords = codewordBytes.length;
// First read into an array of ints
int[] codewordsInts = new int[numCodewords];
for (int i = 0; i < numCodewords; i++) {
codewordsInts[i] = codewordBytes[i] & 0xFF;
}
try {
rsDecoder.decode(codewordsInts, codewordBytes.length - numDataCodewords);
} catch (ReedSolomonException ignored) {
throw ChecksumException.getChecksumInstance();
}
// Copy back into array of bytes -- only need to worry about the bytes that were data
// We don't care about errors in the error-correction codewords
for (int i = 0; i < numDataCodewords; i++) {
codewordBytes[i] = (byte) codewordsInts[i];
}
}
示例3: correctErrors
import com.google.zxing.common.reedsolomon.ReedSolomonException; //导入依赖的package包/类
private void correctErrors(byte[] codewordBytes, int numDataCodewords) throws
ChecksumException {
int i;
int numCodewords = codewordBytes.length;
int[] codewordsInts = new int[numCodewords];
for (i = 0; i < numCodewords; i++) {
codewordsInts[i] = codewordBytes[i] & 255;
}
try {
this.rsDecoder.decode(codewordsInts, codewordBytes.length - numDataCodewords);
for (i = 0; i < numDataCodewords; i++) {
codewordBytes[i] = (byte) codewordsInts[i];
}
} catch (ReedSolomonException e) {
throw ChecksumException.getChecksumInstance();
}
}
示例4: correctErrors
import com.google.zxing.common.reedsolomon.ReedSolomonException; //导入依赖的package包/类
private void correctErrors(byte[] codewordBytes, int start, int dataCodewords, int
ecCodewords, int mode) throws ChecksumException {
int codewords = dataCodewords + ecCodewords;
int divisor = mode == 0 ? 1 : 2;
int[] codewordsInts = new int[(codewords / divisor)];
int i = 0;
while (i < codewords) {
if (mode == 0 || i % 2 == mode - 1) {
codewordsInts[i / divisor] = codewordBytes[i + start] & 255;
}
i++;
}
try {
this.rsDecoder.decode(codewordsInts, ecCodewords / divisor);
i = 0;
while (i < dataCodewords) {
if (mode == 0 || i % 2 == mode - 1) {
codewordBytes[i + start] = (byte) codewordsInts[i / divisor];
}
i++;
}
} catch (ReedSolomonException e) {
throw ChecksumException.getChecksumInstance();
}
}
示例5: correctErrors
import com.google.zxing.common.reedsolomon.ReedSolomonException; //导入依赖的package包/类
/**
* <p>Given data and error-correction codewords received, possibly corrupted by errors, attempts to
* correct the errors in-place using Reed-Solomon error correction.</p>
*
* @param codewordBytes data and error correction codewords
* @param numDataCodewords number of codewords that are data bytes
* @throws ChecksumException if error correction fails
*/
private void correctErrors(byte[] codewordBytes, int numDataCodewords) throws ChecksumException {
int numCodewords = codewordBytes.length;
// First read into an array of ints
int[] codewordsInts = new int[numCodewords];
for (int i = 0; i < numCodewords; i++) {
codewordsInts[i] = codewordBytes[i] & 0xFF;
}
int numECCodewords = codewordBytes.length - numDataCodewords;
try {
rsDecoder.decode(codewordsInts, numECCodewords);
} catch (ReedSolomonException rse) {
throw ChecksumException.getChecksumInstance();
}
// Copy back into array of bytes -- only need to worry about the bytes that were data
// We don't care about errors in the error-correction codewords
for (int i = 0; i < numDataCodewords; i++) {
codewordBytes[i] = (byte) codewordsInts[i];
}
}
示例6: correctErrors
import com.google.zxing.common.reedsolomon.ReedSolomonException; //导入依赖的package包/类
/**
* <p>Given data and error-correction codewords received, possibly corrupted by errors, attempts to
* correct the errors in-place using Reed-Solomon error correction.</p>
*
* @param codewordBytes data and error correction codewords
* @param numDataCodewords number of codewords that are data bytes
* @throws ChecksumException if error correction fails
*/
private void correctErrors(byte[] codewordBytes, int numDataCodewords) throws ChecksumException {
int numCodewords = codewordBytes.length;
// First read into an array of ints
int[] codewordsInts = new int[numCodewords];
for (int i = 0; i < numCodewords; i++) {
codewordsInts[i] = codewordBytes[i] & 0xFF;
}
int numECCodewords = codewordBytes.length - numDataCodewords;
try {
rsDecoder.decode(codewordsInts, numECCodewords);
} catch (ReedSolomonException ignored) {
throw ChecksumException.getChecksumInstance();
}
// Copy back into array of bytes -- only need to worry about the bytes that were data
// We don't care about errors in the error-correction codewords
for (int i = 0; i < numDataCodewords; i++) {
codewordBytes[i] = (byte) codewordsInts[i];
}
}
示例7: correctErrors
import com.google.zxing.common.reedsolomon.ReedSolomonException; //导入依赖的package包/类
/**
* <p>Given data and error-correction codewords received, possibly corrupted by errors, attempts to
* correct the errors in-place using Reed-Solomon error correction.</p>
*
* @param codewordBytes data and error correction codewords
* @param numDataCodewords number of codewords that are data bytes
* @throws com.google.zxing.ChecksumException if error correction fails
*/
private void correctErrors(byte[] codewordBytes, int numDataCodewords) throws ChecksumException {
int numCodewords = codewordBytes.length;
// First read into an array of ints
int[] codewordsInts = new int[numCodewords];
for (int i = 0; i < numCodewords; i++) {
codewordsInts[i] = codewordBytes[i] & 0xFF;
}
int numECCodewords = codewordBytes.length - numDataCodewords;
try {
rsDecoder.decode(codewordsInts, numECCodewords);
} catch (ReedSolomonException ignored) {
throw ChecksumException.getChecksumInstance();
}
// Copy back into array of bytes -- only need to worry about the bytes that were data
// We don't care about errors in the error-correction codewords
for (int i = 0; i < numDataCodewords; i++) {
codewordBytes[i] = (byte) codewordsInts[i];
}
}