當前位置: 首頁>>代碼示例>>Java>>正文


Java BarcodeFormat.UPC_A屬性代碼示例

本文整理匯總了Java中com.google.zxing.BarcodeFormat.UPC_A屬性的典型用法代碼示例。如果您正苦於以下問題:Java BarcodeFormat.UPC_A屬性的具體用法?Java BarcodeFormat.UPC_A怎麽用?Java BarcodeFormat.UPC_A使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在com.google.zxing.BarcodeFormat的用法示例。


在下文中一共展示了BarcodeFormat.UPC_A屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: drawResultPoints

/**
 * Superimpose a line for 1D or dots for 2D to highlight the key features of the barcode.
 *
 * @param barcode   A bitmap of the captured image.
 * @param scaleFactor amount by which thumbnail was scaled
 * @param rawResult The decoded results which contains the points to draw.
 */
private void drawResultPoints(Bitmap barcode, float scaleFactor, Result rawResult) {
  ResultPoint[] points = rawResult.getResultPoints();
  if (points != null && points.length > 0) {
    Canvas canvas = new Canvas(barcode);
    Paint paint = new Paint();
    paint.setColor(getResources().getColor(R.color.result_points));
    if (points.length == 2) {
      paint.setStrokeWidth(4.0f);
      drawLine(canvas, paint, points[0], points[1], scaleFactor);
    } else if (points.length == 4 &&
               (rawResult.getBarcodeFormat() == BarcodeFormat.UPC_A ||
                rawResult.getBarcodeFormat() == BarcodeFormat.EAN_13)) {
      // Hacky special case -- draw two lines, for the barcode and metadata
      drawLine(canvas, paint, points[0], points[1], scaleFactor);
      drawLine(canvas, paint, points[2], points[3], scaleFactor);
    } else {
      paint.setStrokeWidth(10.0f);
      for (ResultPoint point : points) {
        if (point != null) {
          canvas.drawPoint(scaleFactor * point.getX(), scaleFactor * point.getY(), paint);
        }
      }
    }
  }
}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:32,代碼來源:CaptureActivity.java

示例2: parse

@Override
public ProductParsedResult parse(Result result) {
  BarcodeFormat format = result.getBarcodeFormat();
  if (!(format == BarcodeFormat.UPC_A || format == BarcodeFormat.UPC_E ||
        format == BarcodeFormat.EAN_8 || format == BarcodeFormat.EAN_13)) {
    return null;
  }
  String rawText = getMassagedText(result);
  if (!isStringOfDigits(rawText, rawText.length())) {
    return null;
  }
  // Not actually checking the checksum again here    

  String normalizedProductID;
  // Expand UPC-E for purposes of searching
  if (format == BarcodeFormat.UPC_E && rawText.length() == 8) {
    normalizedProductID = UPCEReader.convertUPCEtoUPCA(rawText);
  } else {
    normalizedProductID = rawText;
  }

  return new ProductParsedResult(rawText, normalizedProductID);
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:23,代碼來源:ProductResultParser.java

示例3: parse

public ProductParsedResult parse(Result result) {
    BarcodeFormat format = result.getBarcodeFormat();
    if (format != BarcodeFormat.UPC_A && format != BarcodeFormat.UPC_E && format !=
            BarcodeFormat.EAN_8 && format != BarcodeFormat.EAN_13) {
        return null;
    }
    String rawText = ResultParser.getMassagedText(result);
    if (!ResultParser.isStringOfDigits(rawText, rawText.length())) {
        return null;
    }
    String normalizedProductID;
    if (format == BarcodeFormat.UPC_E && rawText.length() == 8) {
        normalizedProductID = UPCEReader.convertUPCEtoUPCA(rawText);
    } else {
        normalizedProductID = rawText;
    }
    return new ProductParsedResult(rawText, normalizedProductID);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:18,代碼來源:ProductResultParser.java

示例4: drawResultPoints

/**
 * Superimpose a line for 1D or dots for 2D to highlight the key features of the barcode.
 *
 * @param barcode     A bitmap of the captured image.
 * @param scaleFactor amount by which thumbnail was scaled
 * @param rawResult   The decoded results which contains the points to draw.
 */
private void drawResultPoints(Bitmap barcode, float scaleFactor, Result rawResult) {
    ResultPoint[] points = rawResult.getResultPoints();
    if (points != null && points.length > 0) {
        Canvas canvas = new Canvas(barcode);
        Paint paint = new Paint();
        paint.setColor(getResources().getColor(R.color.result_points));
        if (points.length == 2) {
            paint.setStrokeWidth(4.0f);
            drawLine(canvas, paint, points[0], points[1], scaleFactor);
        } else if (points.length == 4 &&
                (rawResult.getBarcodeFormat() == BarcodeFormat.UPC_A ||
                        rawResult.getBarcodeFormat() == BarcodeFormat.EAN_13)) {
            // Hacky special case -- draw two lines, for the barcode and metadata
            drawLine(canvas, paint, points[0], points[1], scaleFactor);
            drawLine(canvas, paint, points[2], points[3], scaleFactor);
        } else {
            paint.setStrokeWidth(10.0f);
            for (ResultPoint point : points) {
                if (point != null) {
                    canvas.drawPoint(scaleFactor * point.getX(), scaleFactor * point.getY(), paint);
                }
            }
        }
    }
}
 
開發者ID:10045125,項目名稱:QrCode,代碼行數:32,代碼來源:QrCodeView.java

示例5: drawResultPoints

/**
 * Superimpose a line for 1D or dots for 2D to highlight the key features of the barcode.
 *
 * @param barcode   A bitmap of the captured image.
 * @param rawResult The decoded results which contains the points to draw.
 */
private void drawResultPoints(Bitmap barcode, Result rawResult) {
  ResultPoint[] points = rawResult.getResultPoints();
  if (points != null && points.length > 0) {
    Canvas canvas = new Canvas(barcode);
    Paint paint = new Paint();
    paint.setColor(0xc099cc00);
    if (points.length == 2) {
      paint.setStrokeWidth(4.0f);
      drawLine(canvas, paint, points[0], points[1]);
    } else if (points.length == 4 &&
               (rawResult.getBarcodeFormat() == BarcodeFormat.UPC_A ||
                rawResult.getBarcodeFormat() == BarcodeFormat.EAN_13)) {
      // Hacky special case -- draw two lines, for the barcode and metadata
      drawLine(canvas, paint, points[0], points[1]);
      drawLine(canvas, paint, points[2], points[3]);
    } else {
      paint.setStrokeWidth(10.0f);
      for (ResultPoint point : points) {
        canvas.drawPoint(point.getX(), point.getY(), paint);
      }
    }
  }
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:29,代碼來源:AppInvCaptureActivity.java

示例6: drawResultPoints

/**
 * Superimpose a line for 1D or dots for 2D to highlight the key features of the barcode.
 *
 * @param barcode     A bitmap of the captured image.
 * @param scaleFactor amount by which thumbnail was scaled
 * @param rawResult   The decoded results which contains the points to draw.
 */
private void drawResultPoints(Bitmap barcode, float scaleFactor, Result rawResult) {
    ResultPoint[] points = rawResult.getResultPoints();
    if (points != null && points.length > 0) {
        Canvas canvas = new Canvas(barcode);
        Paint paint = new Paint();
        paint.setColor(getResources().getColor(R.color.result_points));
        if (points.length == 2) {
            paint.setStrokeWidth(4.0f);
            drawLine(canvas, paint, points[0], points[1], scaleFactor);
        } else if (points.length == 4 &&
                (rawResult.getBarcodeFormat() == BarcodeFormat.UPC_A ||
                        rawResult.getBarcodeFormat() == BarcodeFormat.EAN_13)) {
            // Hacky special case -- draw two lines, for the barcode and metadata
            drawLine(canvas, paint, points[0], points[1], scaleFactor);
            drawLine(canvas, paint, points[2], points[3], scaleFactor);
        } else {
            paint.setStrokeWidth(10.0f);
            for (ResultPoint point : points) {
                if (point != null) {
                    canvas.drawPoint(scaleFactor * point.getX(), scaleFactor * point.getY(),
                            paint);
                }
            }
        }
    }
}
 
開發者ID:kkyflying,項目名稱:CodeScaner,代碼行數:33,代碼來源:CaptureActivity.java

示例7: encode

@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        Map<EncodeHintType,?> hints) throws WriterException {
  if (format != BarcodeFormat.UPC_A) {
    throw new IllegalArgumentException("Can only encode UPC-A, but got " + format);
  }
  return subWriter.encode(preencode(contents), BarcodeFormat.EAN_13, width, height, hints);
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:11,代碼來源:UPCAWriter.java

示例8: drawResultPoints

/**
 * Superimpose a line for 1D or dots for 2D to highlight the key features of
 * the barcode.
 * 
 * @param barcode
 *            A bitmap of the captured image.
 * @param scaleFactor
 *            amount by which thumbnail was scaled
 * @param rawResult
 *            The decoded results which contains the points to draw.
 */
private void drawResultPoints(Bitmap barcode, float scaleFactor,
		Result rawResult) {
	ResultPoint[] points = rawResult.getResultPoints();
	if (points != null && points.length > 0) {
		Canvas canvas = new Canvas(barcode);
		Paint paint = new Paint();
		paint.setColor(getResources().getColor(R.color.result_points));
		if (points.length == 2) {
			paint.setStrokeWidth(4.0f);
			drawLine(canvas, paint, points[0], points[1], scaleFactor);
		} else if (points.length == 4
				&& (rawResult.getBarcodeFormat() == BarcodeFormat.UPC_A || rawResult
						.getBarcodeFormat() == BarcodeFormat.EAN_13)) {
			// Hacky special case -- draw two lines, for the barcode and
			// metadata
			drawLine(canvas, paint, points[0], points[1], scaleFactor);
			drawLine(canvas, paint, points[2], points[3], scaleFactor);
		} else {
			paint.setStrokeWidth(10.0f);
			for (ResultPoint point : points) {
				if (point != null) {
					canvas.drawPoint(scaleFactor * point.getX(),
							scaleFactor * point.getY(), paint);
				}
			}
		}
	}
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:39,代碼來源:CaptureActivity.java

示例9: getBitmapWithResultPoints

/**
 * @param color Color of result points
 * @return {@link Bitmap} with result points on it, or plain bitmap, if no result points
 */
public Bitmap getBitmapWithResultPoints(int color) {
    Bitmap bitmap = getBitmap();
    Bitmap barcode = bitmap;
    ResultPoint[] points = mResult.getResultPoints();

    if (points != null && points.length > 0 && bitmap != null) {
        barcode = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(barcode);
        canvas.drawBitmap(bitmap, 0, 0, null);
        Paint paint = new Paint();
        paint.setColor(color);
        if (points.length == 2) {
            paint.setStrokeWidth(PREVIEW_LINE_WIDTH);
            drawLine(canvas, paint, points[0], points[1], mScaleFactor);
        } else if (points.length == 4 &&
                (mResult.getBarcodeFormat() == BarcodeFormat.UPC_A ||
                        mResult.getBarcodeFormat() == BarcodeFormat.EAN_13)) {
            // Hacky special case -- draw two lines, for the barcode and metadata
            drawLine(canvas, paint, points[0], points[1], mScaleFactor);
            drawLine(canvas, paint, points[2], points[3], mScaleFactor);
        } else {
            paint.setStrokeWidth(PREVIEW_DOT_WIDTH);
            for (ResultPoint point : points) {
                if (point != null) {
                    canvas.drawPoint(point.getX() / mScaleFactor, point.getY() / mScaleFactor, paint);
                }
            }
        }
    }
    return barcode;
}
 
開發者ID:yinhaojun,項目名稱:ZxingForAndroid,代碼行數:35,代碼來源:BarcodeResult.java

示例10: encode

@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        Map<EncodeHintType,?> hints) throws WriterException {
  if (format != BarcodeFormat.UPC_A) {
    throw new IllegalArgumentException("Can only encode UPC-A, but got " + format);
  }
  // Transform a UPC-A code into the equivalent EAN-13 code and write it that way
  return subWriter.encode('0' + contents, BarcodeFormat.EAN_13, width, height, hints);
}
 
開發者ID:10045125,項目名稱:QrCode,代碼行數:12,代碼來源:UPCAWriter.java

示例11: onItemSelected

/**
 * Generates the chosen format from the spinner menu
 */
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long l) {
    String compare = adapterView.getItemAtPosition(position).toString();
    if(compare.equals("BARCODE")){
        format = BarcodeFormat.CODABAR;
    }
    else if(compare.equals("CODE_128")){
        format = BarcodeFormat.CODE_128;
    }
    else if(compare.equals("CODE_39")){
        format = BarcodeFormat.CODE_39;
    }
    else if(compare.equals("EAN_13")){
        format = BarcodeFormat.EAN_13;
    }
    else if(compare.equals("EAN_8")){
        format = BarcodeFormat.EAN_8;
    }
    else if(compare.equals("ITF")){
        format = BarcodeFormat.ITF;
    }
    else if(compare.equals("PDF_417")){
        format = BarcodeFormat.PDF_417;
    }
    else if(compare.equals("UPC_A")){
        format = BarcodeFormat.UPC_A;
    }
}
 
開發者ID:Fr4gorSoftware,項目名稱:SecScanQR,代碼行數:31,代碼來源:BarcodeGenerateActivity.java

示例12: onItemSelected

/**
 * Generates the chosen format from the spinner menu
 */
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    String compare = parent.getItemAtPosition(position).toString();
    if(compare.equals("AZTEC")){
        format = BarcodeFormat.AZTEC;
    }
    else if(compare.equals("CODABAR")){
        format = BarcodeFormat.CODABAR;
    }
    else if(compare.equals("CODE_128")){
        format = BarcodeFormat.CODE_128;
    }
    else if(compare.equals("CODE_39")){
        format = BarcodeFormat.CODE_39;
    }
    else if(compare.equals("EAN_13")){
        format = BarcodeFormat.EAN_13;
    }
    else if(compare.equals("EAN_8")){
        format = BarcodeFormat.EAN_8;
    }
    else if(compare.equals("ITF")){
        format = BarcodeFormat.ITF;
    }
    else if(compare.equals("PDF_417")){
        format = BarcodeFormat.PDF_417;
    }
    else if(compare.equals("QR_CODE")){
        format = BarcodeFormat.QR_CODE;
    }
    else if(compare.equals("UPC_A")){
        format = BarcodeFormat.UPC_A;
    }
}
 
開發者ID:Fr4gorSoftware,項目名稱:SecScanQR,代碼行數:37,代碼來源:GenerateActivity.java

示例13: drawResultPoints

/**
 * Superimpose a line for 1D or dots for 2D to highlight the key features of
 * the barcode.
 *
 * @param barcode
 *            A bitmap of the captured image.
 * @param scaleFactor
 *            amount by which thumbnail was scaled
 * @param rawResult
 *            The decoded results which contains the points to draw.
 */
private void drawResultPoints(Bitmap barcode, float scaleFactor,
                              Result rawResult) {
    ResultPoint[] points = rawResult.getResultPoints();
    if (points != null && points.length > 0) {
        Canvas canvas = new Canvas(barcode);
        Paint paint = new Paint();
        paint.setColor(Color.parseColor("#c099cc00"));
        if (points.length == 2) {
            paint.setStrokeWidth(4.0f);
            drawLine(canvas, paint, points[0], points[1], scaleFactor);
        } else if (points.length == 4
                && (rawResult.getBarcodeFormat() == BarcodeFormat.UPC_A || rawResult
                .getBarcodeFormat() == BarcodeFormat.EAN_13)) {
            // Hacky special case -- draw two lines, for the barcode and
            // metadata
            drawLine(canvas, paint, points[0], points[1], scaleFactor);
            drawLine(canvas, paint, points[2], points[3], scaleFactor);
        } else {
            paint.setStrokeWidth(10.0f);
            for (ResultPoint point : points) {
                if (point != null) {
                    canvas.drawPoint(scaleFactor * point.getX(),
                            scaleFactor * point.getY(), paint);
                }
            }
        }
    }
}
 
開發者ID:yun2win,項目名稱:tvConnect_android,代碼行數:39,代碼來源:CaptureActivity.java

示例14: decodeRow

@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();
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:47,代碼來源:MultiFormatUPCEANReader.java

示例15: getBarcodeFormat

@Override
BarcodeFormat getBarcodeFormat() {
  return BarcodeFormat.UPC_A;
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:4,代碼來源:UPCAReader.java


注:本文中的com.google.zxing.BarcodeFormat.UPC_A屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。