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


Java BarcodeFormat.EAN_13屬性代碼示例

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


在下文中一共展示了BarcodeFormat.EAN_13屬性的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

/**
 * See <a href="http://www.bisg.org/isbn-13/for.dummies.html">ISBN-13 For Dummies</a>
 */
@Override
public ISBNParsedResult parse(Result result) {
  BarcodeFormat format = result.getBarcodeFormat();
  if (format != BarcodeFormat.EAN_13) {
    return null;
  }
  String rawText = getMassagedText(result);
  int length = rawText.length();
  if (length != 13) {
    return null;
  }
  if (!rawText.startsWith("978") && !rawText.startsWith("979")) {
    return null;
  }
 
  return new ISBNParsedResult(rawText);
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:20,代碼來源:ISBNResultParser.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 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

示例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 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

示例6: encode

@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        Map<EncodeHintType,?> hints) throws WriterException {
  if (format != BarcodeFormat.EAN_13) {
    throw new IllegalArgumentException("Can only encode EAN_13, but got " + format);
  }

  return super.encode(contents, format, width, height, hints);
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:12,代碼來源:EAN13Writer.java

示例7: 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

示例8: parse

public ISBNParsedResult parse(Result result) {
    if (result.getBarcodeFormat() != BarcodeFormat.EAN_13) {
        return null;
    }
    String rawText = ResultParser.getMassagedText(result);
    if (rawText.length() != 13) {
        return null;
    }
    if (rawText.startsWith("978") || rawText.startsWith("979")) {
        return new ISBNParsedResult(rawText);
    }
    return null;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:13,代碼來源:ISBNResultParser.java

示例9: 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

示例10: 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

示例11: 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

示例12: encode

public BitMatrix encode(String contents, BarcodeFormat format, int width, int height,
                        Map<EncodeHintType, ?> hints) throws WriterException {
    if (format == BarcodeFormat.EAN_13) {
        return super.encode(contents, format, width, height, hints);
    }
    throw new IllegalArgumentException("Can only encode EAN_13, but got " + format);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:7,代碼來源:EAN13Writer.java

示例13: 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

示例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) {
    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();
}
 
開發者ID:simplezhli,項目名稱:Tesseract-OCR-Scanner,代碼行數:46,代碼來源:MultiFormatUPCEANReader.java

示例15: parseBarCodeString

/**
 * Parse barcodes as BarcodeFormat constants.
 *
 * Supports all iOS codes except [code39mod43, itf14]
 *
 * Additionally supports [codabar, maxicode, rss14, rssexpanded, upca, upceanextension]
 */
private BarcodeFormat parseBarCodeString(String c) {
    if ("aztec".equals(c)) {
        return BarcodeFormat.AZTEC;
    } else if ("ean13".equals(c)) {
        return BarcodeFormat.EAN_13;
    } else if ("ean8".equals(c)) {
        return BarcodeFormat.EAN_8;
    } else if ("qr".equals(c)) {
        return BarcodeFormat.QR_CODE;
    } else if ("pdf417".equals(c)) {
        return BarcodeFormat.PDF_417;
    } else if ("upce".equals(c)) {
        return BarcodeFormat.UPC_E;
    } else if ("datamatrix".equals(c)) {
        return BarcodeFormat.DATA_MATRIX;
    } else if ("code39".equals(c)) {
        return BarcodeFormat.CODE_39;
    } else if ("code93".equals(c)) {
        return BarcodeFormat.CODE_93;
    } else if ("interleaved2of5".equals(c)) {
        return BarcodeFormat.ITF;
    } else if ("codabar".equals(c)) {
        return BarcodeFormat.CODABAR;
    } else if ("code128".equals(c)) {
        return BarcodeFormat.CODE_128;
    } else if ("maxicode".equals(c)) {
        return BarcodeFormat.MAXICODE;
    } else if ("rss14".equals(c)) {
        return BarcodeFormat.RSS_14;
    } else if ("rssexpanded".equals(c)) {
        return BarcodeFormat.RSS_EXPANDED;
    } else if ("upca".equals(c)) {
        return BarcodeFormat.UPC_A;
    } else if ("upceanextension".equals(c)) {
        return BarcodeFormat.UPC_EAN_EXTENSION;
    } else {
        android.util.Log.v("RCTCamera", "Unsupported code.. [" + c + "]");
        return null;
    }
}
 
開發者ID:entria,項目名稱:react-native-camera-face-detector,代碼行數:47,代碼來源:RCTCameraViewFinder.java


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