本文整理汇总了Java中com.google.zxing.Result.getRawBytes方法的典型用法代码示例。如果您正苦于以下问题:Java Result.getRawBytes方法的具体用法?Java Result.getRawBytes怎么用?Java Result.getRawBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.zxing.Result
的用法示例。
在下文中一共展示了Result.getRawBytes方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: translateResultPoints
import com.google.zxing.Result; //导入方法依赖的package包/类
private static Result translateResultPoints(Result result, int xOffset, int yOffset) {
ResultPoint[] oldResultPoints = result.getResultPoints();
if (oldResultPoints == null) {
return result;
}
ResultPoint[] newResultPoints = new ResultPoint[oldResultPoints.length];
for (int i = 0; i < oldResultPoints.length; i++) {
ResultPoint oldPoint = oldResultPoints[i];
if (oldPoint != null) {
newResultPoints[i] = new ResultPoint(oldPoint.getX() + xOffset, oldPoint.getY() + yOffset);
}
}
Result newResult = new Result(result.getText(), result.getRawBytes(), newResultPoints, result.getBarcodeFormat());
newResult.putAllMetadata(result.getResultMetadata());
return newResult;
}
示例2: translateResultPoints
import com.google.zxing.Result; //导入方法依赖的package包/类
private static Result translateResultPoints(Result result, int xOffset, int yOffset) {
ResultPoint[] oldResultPoints = result.getResultPoints();
if (oldResultPoints == null) {
return result;
}
ResultPoint[] newResultPoints = new ResultPoint[oldResultPoints.length];
for (int i = 0; i < oldResultPoints.length; i++) {
ResultPoint oldPoint = oldResultPoints[i];
if (oldPoint != null) {
newResultPoints[i] = new ResultPoint(oldPoint.getX() + xOffset, oldPoint.getY() + yOffset);
}
}
Result newResult = new Result(result.getText(),
result.getRawBytes(),
result.getNumBits(),
newResultPoints,
result.getBarcodeFormat(),
result.getTimestamp());
newResult.putAllMetadata(result.getResultMetadata());
return newResult;
}
示例3: translateResultPoints
import com.google.zxing.Result; //导入方法依赖的package包/类
private static Result translateResultPoints(Result result, int xOffset, int yOffset) {
ResultPoint[] oldResultPoints = result.getResultPoints();
if (oldResultPoints == null) {
return result;
}
ResultPoint[] newResultPoints = new ResultPoint[oldResultPoints.length];
for (int i = 0; i < oldResultPoints.length; i++) {
ResultPoint oldPoint = oldResultPoints[i];
if (oldPoint != null) {
newResultPoints[i] = new ResultPoint(oldPoint.getX() + ((float) xOffset),
oldPoint.getY() + ((float) yOffset));
}
}
Result newResult = new Result(result.getText(), result.getRawBytes(), newResultPoints,
result.getBarcodeFormat());
newResult.putAllMetadata(result.getResultMetadata());
return newResult;
}
示例4: decodeRow
import com.google.zxing.Result; //导入方法依赖的package包/类
@Override
public Result decodeRow(int rowNumber,
BitArray row,
Map<DecodeHintType,?> hints) throws NotFoundException {
// Compute this location once and reuse it on multiple implementations
int[] startGuardPattern = UPCEANReader.findStartGuardPattern(row);
for (UPCEANReader reader : readers) {
Result result;
try {
result = reader.decodeRow(rowNumber, row, startGuardPattern, hints);
} catch (ReaderException ignored) {
continue;
}
// Special case: a 12-digit code encoded in UPC-A is identical to a "0"
// followed by those 12 digits encoded as EAN-13. Each will recognize such a code,
// UPC-A as a 12-digit string and EAN-13 as a 13-digit string starting with "0".
// Individually these are correct and their readers will both read such a code
// and correctly call it EAN-13, or UPC-A, respectively.
//
// In this case, if we've been looking for both types, we'd like to call it
// a UPC-A code. But for efficiency we only run the EAN-13 decoder to also read
// UPC-A. So we special case it here, and convert an EAN-13 result to a UPC-A
// result if appropriate.
//
// But, don't return UPC-A if UPC-A was not a requested format!
boolean ean13MayBeUPCA =
result.getBarcodeFormat() == BarcodeFormat.EAN_13 &&
result.getText().charAt(0) == '0';
@SuppressWarnings("unchecked")
Collection<BarcodeFormat> possibleFormats =
hints == null ? null : (Collection<BarcodeFormat>) hints.get(DecodeHintType.POSSIBLE_FORMATS);
boolean canReturnUPCA = possibleFormats == null || possibleFormats.contains(BarcodeFormat.UPC_A);
if (ean13MayBeUPCA && canReturnUPCA) {
// Transfer the metdata across
Result resultUPCA = new Result(result.getText().substring(1),
result.getRawBytes(),
result.getResultPoints(),
BarcodeFormat.UPC_A);
resultUPCA.putAllMetadata(result.getResultMetadata());
return resultUPCA;
}
return result;
}
throw NotFoundException.getNotFoundInstance();
}
示例5: processStructuredAppend
import com.google.zxing.Result; //导入方法依赖的package包/类
private static List<Result> processStructuredAppend(List<Result> results) {
boolean hasSA = false;
for (Result result : results) {
if (result.getResultMetadata().containsKey(ResultMetadataType
.STRUCTURED_APPEND_SEQUENCE)) {
hasSA = true;
break;
}
}
if (!hasSA) {
return results;
}
List<Result> newResults = new ArrayList();
List<Result> saResults = new ArrayList();
for (Result result2 : results) {
newResults.add(result2);
if (result2.getResultMetadata().containsKey(ResultMetadataType
.STRUCTURED_APPEND_SEQUENCE)) {
saResults.add(result2);
}
}
Collections.sort(saResults, new SAComparator());
StringBuilder concatedText = new StringBuilder();
int rawBytesLen = 0;
int byteSegmentLength = 0;
for (Result saResult : saResults) {
Iterator it;
concatedText.append(saResult.getText());
rawBytesLen += saResult.getRawBytes().length;
if (saResult.getResultMetadata().containsKey(ResultMetadataType.BYTE_SEGMENTS)) {
for (byte[] segment : (Iterable) saResult.getResultMetadata().get
(ResultMetadataType.BYTE_SEGMENTS)) {
byteSegmentLength += segment.length;
}
}
}
byte[] newRawBytes = new byte[rawBytesLen];
byte[] newByteSegment = new byte[byteSegmentLength];
int newRawBytesIndex = 0;
int byteSegmentIndex = 0;
for (Result saResult2 : saResults) {
System.arraycopy(saResult2.getRawBytes(), 0, newRawBytes, newRawBytesIndex, saResult2
.getRawBytes().length);
newRawBytesIndex += saResult2.getRawBytes().length;
if (saResult2.getResultMetadata().containsKey(ResultMetadataType.BYTE_SEGMENTS)) {
it = ((Iterable) saResult2.getResultMetadata().get(ResultMetadataType
.BYTE_SEGMENTS)).iterator();
while (it.hasNext()) {
Object segment2 = (byte[]) it.next();
System.arraycopy(segment2, 0, newByteSegment, byteSegmentIndex, segment2
.length);
byteSegmentIndex += segment2.length;
}
}
}
Result newResult = new Result(concatedText.toString(), newRawBytes, NO_POINTS,
BarcodeFormat.QR_CODE);
if (byteSegmentLength > 0) {
Collection<byte[]> byteSegmentList = new ArrayList();
byteSegmentList.add(newByteSegment);
newResult.putMetadata(ResultMetadataType.BYTE_SEGMENTS, byteSegmentList);
}
newResults.add(newResult);
return newResults;
}
示例6: handleDecodeExternally
import com.google.zxing.Result; //导入方法依赖的package包/类
private void handleDecodeExternally(Result rawResult, ResultHandler resultHandler, Bitmap barcode) {
if (barcode != null) {
viewfinderView.drawResultBitmap(barcode);
}
long resultDurationMS;
if (getIntent() == null) {
resultDurationMS = DEFAULT_INTENT_RESULT_DURATION_MS;
} else {
resultDurationMS = getIntent().getLongExtra(Intents.Scan.RESULT_DISPLAY_DURATION_MS,
DEFAULT_INTENT_RESULT_DURATION_MS);
}
if (copyToClipboard && !resultHandler.areContentsSecure()) {
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
CharSequence text = resultHandler.getDisplayContents();
if (text != null) {
clipboard.setText(text);
}
}
if (source == IntentSource.NATIVE_APP_INTENT) {
// Hand back whatever action they requested - this can be changed to Intents.Scan.ACTION when
// the deprecated intent is retired.
Intent intent = new Intent(getIntent().getAction());
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
intent.putExtra(Intents.Scan.RESULT, rawResult.toString());
intent.putExtra(Intents.Scan.RESULT_FORMAT, rawResult.getBarcodeFormat().toString());
byte[] rawBytes = rawResult.getRawBytes();
if (rawBytes != null && rawBytes.length > 0) {
intent.putExtra(Intents.Scan.RESULT_BYTES, rawBytes);
}
Map<ResultMetadataType,?> metadata = rawResult.getResultMetadata();
if (metadata != null) {
if (metadata.containsKey(ResultMetadataType.UPC_EAN_EXTENSION)) {
intent.putExtra(Intents.Scan.RESULT_UPC_EAN_EXTENSION,
metadata.get(ResultMetadataType.UPC_EAN_EXTENSION).toString());
}
Integer orientation = (Integer) metadata.get(ResultMetadataType.ORIENTATION);
if (orientation != null) {
intent.putExtra(Intents.Scan.RESULT_ORIENTATION, orientation.intValue());
}
String ecLevel = (String) metadata.get(ResultMetadataType.ERROR_CORRECTION_LEVEL);
if (ecLevel != null) {
intent.putExtra(Intents.Scan.RESULT_ERROR_CORRECTION_LEVEL, ecLevel);
}
Iterable<byte[]> byteSegments = (Iterable<byte[]>) metadata.get(ResultMetadataType.BYTE_SEGMENTS);
if (byteSegments != null) {
int i = 0;
for (byte[] byteSegment : byteSegments) {
intent.putExtra(Intents.Scan.RESULT_BYTE_SEGMENTS_PREFIX + i, byteSegment);
i++;
}
}
}
sendReplyMessage(Constants.return_scan_result, intent, resultDurationMS);
}
}
示例7: decodeRow
import com.google.zxing.Result; //导入方法依赖的package包/类
@Override
public Result decodeRow(int rowNumber,
BitArray row,
Map<DecodeHintType,?> hints) throws NotFoundException {
// Compute this location once and reuse it on multiple implementations
int[] startGuardPattern = UPCEANReader.findStartGuardPattern(row);
for (UPCEANReader reader : readers) {
try {
Result result = reader.decodeRow(rowNumber, row, startGuardPattern, hints);
// Special case: a 12-digit code encoded in UPC-A is identical to a "0"
// followed by those 12 digits encoded as EAN-13. Each will recognize such a code,
// UPC-A as a 12-digit string and EAN-13 as a 13-digit string starting with "0".
// Individually these are correct and their readers will both read such a code
// and correctly call it EAN-13, or UPC-A, respectively.
//
// In this case, if we've been looking for both types, we'd like to call it
// a UPC-A code. But for efficiency we only run the EAN-13 decoder to also read
// UPC-A. So we special case it here, and convert an EAN-13 result to a UPC-A
// result if appropriate.
//
// But, don't return UPC-A if UPC-A was not a requested format!
boolean ean13MayBeUPCA =
result.getBarcodeFormat() == BarcodeFormat.EAN_13 &&
result.getText().charAt(0) == '0';
@SuppressWarnings("unchecked")
Collection<BarcodeFormat> possibleFormats =
hints == null ? null : (Collection<BarcodeFormat>) hints.get(DecodeHintType.POSSIBLE_FORMATS);
boolean canReturnUPCA = possibleFormats == null || possibleFormats.contains(BarcodeFormat.UPC_A);
if (ean13MayBeUPCA && canReturnUPCA) {
// Transfer the metdata across
Result resultUPCA = new Result(result.getText().substring(1),
result.getRawBytes(),
result.getResultPoints(),
BarcodeFormat.UPC_A);
resultUPCA.putAllMetadata(result.getResultMetadata());
return resultUPCA;
}
return result;
} catch (ReaderException ignored) {
// continue
}
}
throw NotFoundException.getNotFoundInstance();
}