Java 类com.google.zxing.pdf417.encoder.PDF417 实例源码

项目:weex-3d-map    文件:PDF417Writer.java   
/**
 * Takes encoder, accounts for width/height, and retrieves bit matrix
 */
private static BitMatrix bitMatrixFromEncoder(PDF417 encoder,
                                              String contents,
                                              int errorCorrectionLevel,
                                              int width,
                                              int height,
                                              int margin) throws WriterException {
  encoder.generateBarcodeLogic(contents, errorCorrectionLevel);

  int aspectRatio = 4;
  byte[][] originalScale = encoder.getBarcodeMatrix().getScaledMatrix(1, aspectRatio);
  boolean rotated = false;
  if ((height > width) ^ (originalScale[0].length < originalScale.length)) {
    originalScale = rotateArray(originalScale);
    rotated = true;
  }

  int scaleX = width / originalScale[0].length;
  int scaleY = height / originalScale.length;

  int scale;
  if (scaleX < scaleY) {
    scale = scaleX;
  } else {
    scale = scaleY;
  }

  if (scale > 1) {
    byte[][] scaledMatrix =
        encoder.getBarcodeMatrix().getScaledMatrix(scale, scale * aspectRatio);
    if (rotated) {
      scaledMatrix = rotateArray(scaledMatrix);
    }
    return bitMatrixFrombitArray(scaledMatrix, margin);
  }
  return bitMatrixFrombitArray(originalScale, margin);
}
项目:boohee_v5.6    文件:PDF417Writer.java   
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height,
                        Map<EncodeHintType, ?> hints) throws WriterException {
    if (format != BarcodeFormat.PDF_417) {
        throw new IllegalArgumentException("Can only encode PDF_417, but got " + format);
    }
    PDF417 encoder = new PDF417();
    int margin = 30;
    int errorCorrectionLevel = 2;
    if (hints != null) {
        if (hints.containsKey(EncodeHintType.PDF417_COMPACT)) {
            encoder.setCompact(((Boolean) hints.get(EncodeHintType.PDF417_COMPACT))
                    .booleanValue());
        }
        if (hints.containsKey(EncodeHintType.PDF417_COMPACTION)) {
            encoder.setCompaction((Compaction) hints.get(EncodeHintType.PDF417_COMPACTION));
        }
        if (hints.containsKey(EncodeHintType.PDF417_DIMENSIONS)) {
            Dimensions dimensions = (Dimensions) hints.get(EncodeHintType.PDF417_DIMENSIONS);
            encoder.setDimensions(dimensions.getMaxCols(), dimensions.getMinCols(),
                    dimensions.getMaxRows(), dimensions.getMinRows());
        }
        if (hints.containsKey(EncodeHintType.MARGIN)) {
            margin = ((Number) hints.get(EncodeHintType.MARGIN)).intValue();
        }
        if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {
            errorCorrectionLevel = ((Number) hints.get(EncodeHintType.ERROR_CORRECTION))
                    .intValue();
        }
        if (hints.containsKey(EncodeHintType.CHARACTER_SET)) {
            encoder.setEncoding(Charset.forName((String) hints.get(EncodeHintType
                    .CHARACTER_SET)));
        }
    }
    return bitMatrixFromEncoder(encoder, contents, errorCorrectionLevel, width, height, margin);
}
项目:boohee_v5.6    文件:PDF417Writer.java   
private static BitMatrix bitMatrixFromEncoder(PDF417 encoder, String contents, int
        errorCorrectionLevel, int width, int height, int margin) throws WriterException {
    int i;
    int scale;
    encoder.generateBarcodeLogic(contents, errorCorrectionLevel);
    byte[][] originalScale = encoder.getBarcodeMatrix().getScaledMatrix(1, 4);
    boolean rotated = false;
    int i2 = height > width ? 1 : 0;
    if (originalScale[0].length < originalScale.length) {
        i = 1;
    } else {
        i = 0;
    }
    if ((i2 ^ i) != 0) {
        originalScale = rotateArray(originalScale);
        rotated = true;
    }
    int scaleX = width / originalScale[0].length;
    int scaleY = height / originalScale.length;
    if (scaleX < scaleY) {
        scale = scaleX;
    } else {
        scale = scaleY;
    }
    if (scale <= 1) {
        return bitMatrixFrombitArray(originalScale, margin);
    }
    byte[][] scaledMatrix = encoder.getBarcodeMatrix().getScaledMatrix(scale, scale * 4);
    if (rotated) {
        scaledMatrix = rotateArray(scaledMatrix);
    }
    return bitMatrixFrombitArray(scaledMatrix, margin);
}
项目:PortraitZXing    文件:PDF417Writer.java   
/**
 * Takes encoder, accounts for width/height, and retrieves bit matrix
 */
private static BitMatrix bitMatrixFromEncoder(PDF417 encoder,
                                              String contents,
                                              int errorCorrectionLevel,
                                              int width,
                                              int height,
                                              int margin) throws WriterException {
  encoder.generateBarcodeLogic(contents, errorCorrectionLevel);

  int aspectRatio = 4;
  byte[][] originalScale = encoder.getBarcodeMatrix().getScaledMatrix(1, aspectRatio);
  boolean rotated = false;
  if ((height > width) ^ (originalScale[0].length < originalScale.length)) {
    originalScale = rotateArray(originalScale);
    rotated = true;
  }

  int scaleX = width / originalScale[0].length;
  int scaleY = height / originalScale.length;

  int scale;
  if (scaleX < scaleY) {
    scale = scaleX;
  } else {
    scale = scaleY;
  }

  if (scale > 1) {
    byte[][] scaledMatrix =
        encoder.getBarcodeMatrix().getScaledMatrix(scale, scale * aspectRatio);
    if (rotated) {
      scaledMatrix = rotateArray(scaledMatrix);
    }
    return bitMatrixFrombitArray(scaledMatrix, margin);
  }
  return bitMatrixFrombitArray(originalScale, margin);
}
项目:PortraitZXing    文件:PDF417Writer.java   
/**
 * Takes encoder, accounts for width/height, and retrieves bit matrix
 */
private static BitMatrix bitMatrixFromEncoder(PDF417 encoder,
                                              String contents,
                                              int errorCorrectionLevel,
                                              int width,
                                              int height,
                                              int margin) throws WriterException {
  encoder.generateBarcodeLogic(contents, errorCorrectionLevel);

  int aspectRatio = 4;
  byte[][] originalScale = encoder.getBarcodeMatrix().getScaledMatrix(1, aspectRatio);
  boolean rotated = false;
  if ((height > width) ^ (originalScale[0].length < originalScale.length)) {
    originalScale = rotateArray(originalScale);
    rotated = true;
  }

  int scaleX = width / originalScale[0].length;
  int scaleY = height / originalScale.length;

  int scale;
  if (scaleX < scaleY) {
    scale = scaleX;
  } else {
    scale = scaleY;
  }

  if (scale > 1) {
    byte[][] scaledMatrix =
        encoder.getBarcodeMatrix().getScaledMatrix(scale, scale * aspectRatio);
    if (rotated) {
      scaledMatrix = rotateArray(scaledMatrix);
    }
    return bitMatrixFrombitArray(scaledMatrix, margin);
  }
  return bitMatrixFrombitArray(originalScale, margin);
}
项目:ZXing-Orient    文件:PDF417Writer.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        Map<EncodeHintType,?> hints) throws WriterException {
  if (format != BarcodeFormat.PDF_417) {
    throw new IllegalArgumentException("Can only encode PDF_417, but got " + format);
  }

  PDF417 encoder = new PDF417();
  int margin = WHITE_SPACE;

  if (hints != null) {
    if (hints.containsKey(EncodeHintType.PDF417_COMPACT)) {
      encoder.setCompact((Boolean) hints.get(EncodeHintType.PDF417_COMPACT));
    }
    if (hints.containsKey(EncodeHintType.PDF417_COMPACTION)) {
      encoder.setCompaction((Compaction) hints.get(EncodeHintType.PDF417_COMPACTION));
    }
    if (hints.containsKey(EncodeHintType.PDF417_DIMENSIONS)) {
      Dimensions dimensions = (Dimensions) hints.get(EncodeHintType.PDF417_DIMENSIONS);
      encoder.setDimensions(dimensions.getMaxCols(),
                            dimensions.getMinCols(),
                            dimensions.getMaxRows(),
                            dimensions.getMinRows());
    }
    if (hints.containsKey(EncodeHintType.MARGIN)) {
      margin = ((Number) hints.get(EncodeHintType.MARGIN)).intValue();
    }
    if (hints.containsKey(EncodeHintType.CHARACTER_SET)) {
      String encoding = (String) hints.get(EncodeHintType.CHARACTER_SET);
      encoder.setEncoding(Charset.forName(encoding));
    }
  }

  return bitMatrixFromEncoder(encoder, contents, width, height, margin);
}
项目:ZXing-Orient    文件:PDF417Writer.java   
/**
 * Takes encoder, accounts for width/height, and retrieves bit matrix
 */
private static BitMatrix bitMatrixFromEncoder(PDF417 encoder,
                                              String contents,
                                              int width,
                                              int height,
                                              int margin) throws WriterException {
  int errorCorrectionLevel = 2;
  encoder.generateBarcodeLogic(contents, errorCorrectionLevel);

  int lineThickness = 2;
  int aspectRatio = 4;
  byte[][] originalScale = encoder.getBarcodeMatrix().getScaledMatrix(lineThickness, aspectRatio * lineThickness);
  boolean rotated = false;
  if ((height > width) ^ (originalScale[0].length < originalScale.length)) {
    originalScale = rotateArray(originalScale);
    rotated = true;
  }

  int scaleX = width / originalScale[0].length;
  int scaleY = height / originalScale.length;

  int scale;
  if (scaleX < scaleY) {
    scale = scaleX;
  } else {
    scale = scaleY;
  }

  if (scale > 1) {
    byte[][] scaledMatrix =
        encoder.getBarcodeMatrix().getScaledMatrix(scale * lineThickness, scale * aspectRatio * lineThickness);
    if (rotated) {
      scaledMatrix = rotateArray(scaledMatrix);
    }
    return bitMatrixFrombitArray(scaledMatrix, margin);
  }
  return bitMatrixFrombitArray(originalScale, margin);
}
项目:event-app    文件:PDF417Writer.java   
/**
 * Takes encoder, accounts for width/height, and retrieves bit matrix
 */
private static BitMatrix bitMatrixFromEncoder(PDF417 encoder,
                                              String contents,
                                              int errorCorrectionLevel,
                                              int width,
                                              int height,
                                              int margin) throws WriterException {
  encoder.generateBarcodeLogic(contents, errorCorrectionLevel);

  int aspectRatio = 4;
  byte[][] originalScale = encoder.getBarcodeMatrix().getScaledMatrix(1, aspectRatio);
  boolean rotated = false;
  if ((height > width) ^ (originalScale[0].length < originalScale.length)) {
    originalScale = rotateArray(originalScale);
    rotated = true;
  }

  int scaleX = width / originalScale[0].length;
  int scaleY = height / originalScale.length;

  int scale;
  if (scaleX < scaleY) {
    scale = scaleX;
  } else {
    scale = scaleY;
  }

  if (scale > 1) {
    byte[][] scaledMatrix =
        encoder.getBarcodeMatrix().getScaledMatrix(scale, scale * aspectRatio);
    if (rotated) {
      scaledMatrix = rotateArray(scaledMatrix);
    }
    return bitMatrixFrombitArray(scaledMatrix, margin);
  }
  return bitMatrixFrombitArray(originalScale, margin);
}
项目:weex-analyzer-android    文件:PDF417Writer.java   
/**
 * Takes encoder, accounts for width/height, and retrieves bit matrix
 */
private static BitMatrix bitMatrixFromEncoder(PDF417 encoder,
                                              String contents,
                                              int errorCorrectionLevel,
                                              int width,
                                              int height,
                                              int margin) throws WriterException {
  encoder.generateBarcodeLogic(contents, errorCorrectionLevel);

  int aspectRatio = 4;
  byte[][] originalScale = encoder.getBarcodeMatrix().getScaledMatrix(1, aspectRatio);
  boolean rotated = false;
  if ((height > width) ^ (originalScale[0].length < originalScale.length)) {
    originalScale = rotateArray(originalScale);
    rotated = true;
  }

  int scaleX = width / originalScale[0].length;
  int scaleY = height / originalScale.length;

  int scale;
  if (scaleX < scaleY) {
    scale = scaleX;
  } else {
    scale = scaleY;
  }

  if (scale > 1) {
    byte[][] scaledMatrix =
        encoder.getBarcodeMatrix().getScaledMatrix(scale, scale * aspectRatio);
    if (rotated) {
      scaledMatrix = rotateArray(scaledMatrix);
    }
    return bitMatrixFrombitArray(scaledMatrix, margin);
  }
  return bitMatrixFrombitArray(originalScale, margin);
}
项目:weex-3d-map    文件:PDF417Writer.java   
/**
 * Takes encoder, accounts for width/height, and retrieves bit matrix
 */
private static BitMatrix bitMatrixFromEncoder(PDF417 encoder,
                                              String contents,
                                              int errorCorrectionLevel,
                                              int width,
                                              int height,
                                              int margin) throws WriterException {
  encoder.generateBarcodeLogic(contents, errorCorrectionLevel);

  int aspectRatio = 4;
  byte[][] originalScale = encoder.getBarcodeMatrix().getScaledMatrix(1, aspectRatio);
  boolean rotated = false;
  if ((height > width) ^ (originalScale[0].length < originalScale.length)) {
    originalScale = rotateArray(originalScale);
    rotated = true;
  }

  int scaleX = width / originalScale[0].length;
  int scaleY = height / originalScale.length;

  int scale;
  if (scaleX < scaleY) {
    scale = scaleX;
  } else {
    scale = scaleY;
  }

  if (scale > 1) {
    byte[][] scaledMatrix =
        encoder.getBarcodeMatrix().getScaledMatrix(scale, scale * aspectRatio);
    if (rotated) {
      scaledMatrix = rotateArray(scaledMatrix);
    }
    return bitMatrixFrombitArray(scaledMatrix, margin);
  }
  return bitMatrixFrombitArray(originalScale, margin);
}
项目:Weex-TestDemo    文件:PDF417Writer.java   
/**
 * Takes encoder, accounts for width/height, and retrieves bit matrix
 */
private static BitMatrix bitMatrixFromEncoder(PDF417 encoder,
                                              String contents,
                                              int errorCorrectionLevel,
                                              int width,
                                              int height,
                                              int margin) throws WriterException {
  encoder.generateBarcodeLogic(contents, errorCorrectionLevel);

  int aspectRatio = 4;
  byte[][] originalScale = encoder.getBarcodeMatrix().getScaledMatrix(1, aspectRatio);
  boolean rotated = false;
  if ((height > width) ^ (originalScale[0].length < originalScale.length)) {
    originalScale = rotateArray(originalScale);
    rotated = true;
  }

  int scaleX = width / originalScale[0].length;
  int scaleY = height / originalScale.length;

  int scale;
  if (scaleX < scaleY) {
    scale = scaleX;
  } else {
    scale = scaleY;
  }

  if (scale > 1) {
    byte[][] scaledMatrix =
        encoder.getBarcodeMatrix().getScaledMatrix(scale, scale * aspectRatio);
    if (rotated) {
      scaledMatrix = rotateArray(scaledMatrix);
    }
    return bitMatrixFrombitArray(scaledMatrix, margin);
  }
  return bitMatrixFrombitArray(originalScale, margin);
}
项目:Cardstore    文件:PDF417Writer.java   
/**
 * Takes encoder, accounts for width/height, and retrieves bit matrix
 */
private static BitMatrix bitMatrixFromEncoder(PDF417 encoder,
                                              String contents,
                                              int errorCorrectionLevel,
                                              int width,
                                              int height,
                                              int margin) throws WriterException {
  encoder.generateBarcodeLogic(contents, errorCorrectionLevel);

  int aspectRatio = 4;
  byte[][] originalScale = encoder.getBarcodeMatrix().getScaledMatrix(1, aspectRatio);
  boolean rotated = false;
  if ((height > width) ^ (originalScale[0].length < originalScale.length)) {
    originalScale = rotateArray(originalScale);
    rotated = true;
  }

  int scaleX = width / originalScale[0].length;
  int scaleY = height / originalScale.length;

  int scale;
  if (scaleX < scaleY) {
    scale = scaleX;
  } else {
    scale = scaleY;
  }

  if (scale > 1) {
    byte[][] scaledMatrix =
        encoder.getBarcodeMatrix().getScaledMatrix(scale, scale * aspectRatio);
    if (rotated) {
      scaledMatrix = rotateArray(scaledMatrix);
    }
    return bitMatrixFrombitArray(scaledMatrix, margin);
  }
  return bitMatrixFrombitArray(originalScale, margin);
}
项目:QrScan_Demo    文件:PDF417Writer.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        Map<EncodeHintType,?> hints) throws WriterException {
  if (format != BarcodeFormat.PDF_417) {
    throw new IllegalArgumentException("Can only encode PDF_417, but got " + format);
  }

  PDF417 encoder = new PDF417();
  int margin = WHITE_SPACE;

  if (hints != null) {
    if (hints.containsKey(EncodeHintType.PDF417_COMPACT)) {
      encoder.setCompact((Boolean) hints.get(EncodeHintType.PDF417_COMPACT));
    }
    if (hints.containsKey(EncodeHintType.PDF417_COMPACTION)) {
      encoder.setCompaction((Compaction) hints.get(EncodeHintType.PDF417_COMPACTION));
    }
    if (hints.containsKey(EncodeHintType.PDF417_DIMENSIONS)) {
      Dimensions dimensions = (Dimensions) hints.get(EncodeHintType.PDF417_DIMENSIONS);
      encoder.setDimensions(dimensions.getMaxCols(),
                            dimensions.getMinCols(),
                            dimensions.getMaxRows(),
                            dimensions.getMinRows());
    }
    if (hints.containsKey(EncodeHintType.MARGIN)) {
      margin = ((Number) hints.get(EncodeHintType.MARGIN)).intValue();
    }
    if (hints.containsKey(EncodeHintType.CHARACTER_SET)) {
      String encoding = (String) hints.get(EncodeHintType.CHARACTER_SET);
      encoder.setEncoding(Charset.forName(encoding));
    }
  }

  return bitMatrixFromEncoder(encoder, contents, width, height, margin);
}
项目:QrScan_Demo    文件:PDF417Writer.java   
/**
 * Takes encoder, accounts for width/height, and retrieves bit matrix
 */
private static BitMatrix bitMatrixFromEncoder(PDF417 encoder,
                                              String contents,
                                              int width,
                                              int height,
                                              int margin) throws WriterException {
  int errorCorrectionLevel = 2;
  encoder.generateBarcodeLogic(contents, errorCorrectionLevel);

  int lineThickness = 2;
  int aspectRatio = 4;
  byte[][] originalScale = encoder.getBarcodeMatrix().getScaledMatrix(lineThickness, aspectRatio * lineThickness);
  boolean rotated = false;
  if ((height > width) ^ (originalScale[0].length < originalScale.length)) {
    originalScale = rotateArray(originalScale);
    rotated = true;
  }

  int scaleX = width / originalScale[0].length;
  int scaleY = height / originalScale.length;

  int scale;
  if (scaleX < scaleY) {
    scale = scaleX;
  } else {
    scale = scaleY;
  }

  if (scale > 1) {
    byte[][] scaledMatrix =
        encoder.getBarcodeMatrix().getScaledMatrix(scale * lineThickness, scale * aspectRatio * lineThickness);
    if (rotated) {
      scaledMatrix = rotateArray(scaledMatrix);
    }
    return bitMatrixFrombitArray(scaledMatrix, margin);
  }
  return bitMatrixFrombitArray(originalScale, margin);
}
项目:weex    文件:PDF417Writer.java   
/**
 * Takes encoder, accounts for width/height, and retrieves bit matrix
 */
private static BitMatrix bitMatrixFromEncoder(PDF417 encoder,
                                              String contents,
                                              int errorCorrectionLevel,
                                              int width,
                                              int height,
                                              int margin) throws WriterException {
  encoder.generateBarcodeLogic(contents, errorCorrectionLevel);

  int aspectRatio = 4;
  byte[][] originalScale = encoder.getBarcodeMatrix().getScaledMatrix(1, aspectRatio);
  boolean rotated = false;
  if ((height > width) ^ (originalScale[0].length < originalScale.length)) {
    originalScale = rotateArray(originalScale);
    rotated = true;
  }

  int scaleX = width / originalScale[0].length;
  int scaleY = height / originalScale.length;

  int scale;
  if (scaleX < scaleY) {
    scale = scaleX;
  } else {
    scale = scaleY;
  }

  if (scale > 1) {
    byte[][] scaledMatrix =
        encoder.getBarcodeMatrix().getScaledMatrix(scale, scale * aspectRatio);
    if (rotated) {
      scaledMatrix = rotateArray(scaledMatrix);
    }
    return bitMatrixFrombitArray(scaledMatrix, margin);
  }
  return bitMatrixFrombitArray(originalScale, margin);
}
项目:TrueTone    文件:PDF417Writer.java   
/**
 * Takes encoder, accounts for width/height, and retrieves bit matrix
 */
private static BitMatrix bitMatrixFromEncoder(PDF417 encoder,
                                              String contents,
                                              int width,
                                              int height,
                                              int margin) throws WriterException {
    int errorCorrectionLevel = 2;
    encoder.generateBarcodeLogic(contents, errorCorrectionLevel);

    int lineThickness = 2;
    int aspectRatio = 4;
    byte[][] originalScale = encoder.getBarcodeMatrix().getScaledMatrix(lineThickness, aspectRatio * lineThickness);
    boolean rotated = false;
    if ((height > width) ^ (originalScale[0].length < originalScale.length)) {
        originalScale = rotateArray(originalScale);
        rotated = true;
    }

    int scaleX = width / originalScale[0].length;
    int scaleY = height / originalScale.length;

    int scale;
    if (scaleX < scaleY) {
        scale = scaleX;
    } else {
        scale = scaleY;
    }

    if (scale > 1) {
        byte[][] scaledMatrix =
                encoder.getBarcodeMatrix().getScaledMatrix(scale * lineThickness, scale * aspectRatio * lineThickness);
        if (rotated) {
            scaledMatrix = rotateArray(scaledMatrix);
        }
        return bitMatrixFrombitArray(scaledMatrix, margin);
    }
    return bitMatrixFrombitArray(originalScale, margin);
}
项目:TrueTone    文件:PDF417Writer.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        Map<EncodeHintType, ?> hints) throws WriterException {
    if (format != BarcodeFormat.PDF_417) {
        throw new IllegalArgumentException("Can only encode PDF_417, but got " + format);
    }

    PDF417 encoder = new PDF417();
    int margin = WHITE_SPACE;

    if (hints != null) {
        if (hints.containsKey(EncodeHintType.PDF417_COMPACT)) {
            encoder.setCompact((Boolean) hints.get(EncodeHintType.PDF417_COMPACT));
        }
        if (hints.containsKey(EncodeHintType.PDF417_COMPACTION)) {
            encoder.setCompaction((Compaction) hints.get(EncodeHintType.PDF417_COMPACTION));
        }
        if (hints.containsKey(EncodeHintType.PDF417_DIMENSIONS)) {
            Dimensions dimensions = (Dimensions) hints.get(EncodeHintType.PDF417_DIMENSIONS);
            encoder.setDimensions(dimensions.getMaxCols(),
                    dimensions.getMinCols(),
                    dimensions.getMaxRows(),
                    dimensions.getMinRows());
        }
        if (hints.containsKey(EncodeHintType.MARGIN)) {
            margin = ((Number) hints.get(EncodeHintType.MARGIN)).intValue();
        }
        if (hints.containsKey(EncodeHintType.CHARACTER_SET)) {
            String encoding = (String) hints.get(EncodeHintType.CHARACTER_SET);
            encoder.setEncoding(Charset.forName(encoding));
        }
    }

    return bitMatrixFromEncoder(encoder, contents, width, height, margin);
}
项目:Discounty    文件:PDF417Writer.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        Map<EncodeHintType, ?> hints) throws WriterException {
    if (format != BarcodeFormat.PDF_417) {
        throw new IllegalArgumentException("Can only encode PDF_417, but got " + format);
    }

    PDF417 encoder = new PDF417();

    if (hints != null) {
        if (hints.containsKey(EncodeHintType.PDF417_COMPACT)) {
            encoder.setCompact((Boolean) hints.get(EncodeHintType.PDF417_COMPACT));
        }
        if (hints.containsKey(EncodeHintType.PDF417_COMPACTION)) {
            encoder.setCompaction((Compaction) hints.get(EncodeHintType.PDF417_COMPACTION));
        }
        if (hints.containsKey(EncodeHintType.PDF417_DIMENSIONS)) {
            Dimensions dimensions = (Dimensions) hints.get(EncodeHintType.PDF417_DIMENSIONS);
            encoder.setDimensions(dimensions.getMaxCols(),
                    dimensions.getMinCols(),
                    dimensions.getMaxRows(),
                    dimensions.getMinRows());
        }
    }

    return bitMatrixFromEncoder(encoder, contents, width, height);
}
项目:Discounty    文件:PDF417Writer.java   
/**
 * Takes encoder, accounts for width/height, and retrieves bit matrix
 */
private static BitMatrix bitMatrixFromEncoder(PDF417 encoder,
                                              String contents,
                                              int width,
                                              int height) throws WriterException {
    int errorCorrectionLevel = 2;
    encoder.generateBarcodeLogic(contents, errorCorrectionLevel);

    int lineThickness = 2;
    int aspectRatio = 4;
    byte[][] originalScale = encoder.getBarcodeMatrix().getScaledMatrix(lineThickness, aspectRatio * lineThickness);
    boolean rotated = false;
    if ((height > width) ^ (originalScale[0].length < originalScale.length)) {
        originalScale = rotateArray(originalScale);
        rotated = true;
    }

    int scaleX = width / originalScale[0].length;
    int scaleY = height / originalScale.length;

    int scale;
    if (scaleX < scaleY) {
        scale = scaleX;
    } else {
        scale = scaleY;
    }

    if (scale > 1) {
        byte[][] scaledMatrix =
                encoder.getBarcodeMatrix().getScaledMatrix(scale * lineThickness, scale * aspectRatio * lineThickness);
        if (rotated) {
            scaledMatrix = rotateArray(scaledMatrix);
        }
        return bitMatrixFrombitArray(scaledMatrix);
    }
    return bitMatrixFrombitArray(originalScale);
}
项目:bushido-android-app    文件:PDF417Writer.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        Map<EncodeHintType,?> hints) throws WriterException {
  if (format != BarcodeFormat.PDF_417) {
    throw new IllegalArgumentException("Can only encode PDF_417, but got " + format);
  }

  PDF417 encoder = new PDF417();
  int margin = WHITE_SPACE;

  if (hints != null) {
    if (hints.containsKey(EncodeHintType.PDF417_COMPACT)) {
      encoder.setCompact((Boolean) hints.get(EncodeHintType.PDF417_COMPACT));
    }
    if (hints.containsKey(EncodeHintType.PDF417_COMPACTION)) {
      encoder.setCompaction((Compaction) hints.get(EncodeHintType.PDF417_COMPACTION));
    }
    if (hints.containsKey(EncodeHintType.PDF417_DIMENSIONS)) {
      Dimensions dimensions = (Dimensions) hints.get(EncodeHintType.PDF417_DIMENSIONS);
      encoder.setDimensions(dimensions.getMaxCols(),
                            dimensions.getMinCols(),
                            dimensions.getMaxRows(),
                            dimensions.getMinRows());
    }
    if (hints.containsKey(EncodeHintType.MARGIN)) {
      margin = ((Number) hints.get(EncodeHintType.MARGIN)).intValue();
    }
    if (hints.containsKey(EncodeHintType.CHARACTER_SET)) {
      String encoding = (String) hints.get(EncodeHintType.CHARACTER_SET);
      encoder.setEncoding(Charset.forName(encoding));
    }
  }

  return bitMatrixFromEncoder(encoder, contents, width, height, margin);
}
项目:bushido-android-app    文件:PDF417Writer.java   
/**
 * Takes encoder, accounts for width/height, and retrieves bit matrix
 */
private static BitMatrix bitMatrixFromEncoder(PDF417 encoder,
                                              String contents,
                                              int width,
                                              int height,
                                              int margin) throws WriterException {
  int errorCorrectionLevel = 2;
  encoder.generateBarcodeLogic(contents, errorCorrectionLevel);

  int lineThickness = 2;
  int aspectRatio = 4;
  byte[][] originalScale = encoder.getBarcodeMatrix().getScaledMatrix(lineThickness, aspectRatio * lineThickness);
  boolean rotated = false;
  if ((height > width) ^ (originalScale[0].length < originalScale.length)) {
    originalScale = rotateArray(originalScale);
    rotated = true;
  }

  int scaleX = width / originalScale[0].length;
  int scaleY = height / originalScale.length;

  int scale;
  if (scaleX < scaleY) {
    scale = scaleX;
  } else {
    scale = scaleY;
  }

  if (scale > 1) {
    byte[][] scaledMatrix =
        encoder.getBarcodeMatrix().getScaledMatrix(scale * lineThickness, scale * aspectRatio * lineThickness);
    if (rotated) {
      scaledMatrix = rotateArray(scaledMatrix);
    }
    return bitMatrixFrombitArray(scaledMatrix, margin);
  }
  return bitMatrixFrombitArray(originalScale, margin);
}
项目:Android-Birdcopy-Application    文件:PDF417Writer.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        Map<EncodeHintType,?> hints) throws WriterException {
  if (format != BarcodeFormat.PDF_417) {
    throw new IllegalArgumentException("Can only encode PDF_417, but got " + format);
  }

  PDF417 encoder = new PDF417();
  int margin = WHITE_SPACE;

  if (hints != null) {
    if (hints.containsKey(EncodeHintType.PDF417_COMPACT)) {
      encoder.setCompact((Boolean) hints.get(EncodeHintType.PDF417_COMPACT));
    }
    if (hints.containsKey(EncodeHintType.PDF417_COMPACTION)) {
      encoder.setCompaction((Compaction) hints.get(EncodeHintType.PDF417_COMPACTION));
    }
    if (hints.containsKey(EncodeHintType.PDF417_DIMENSIONS)) {
      Dimensions dimensions = (Dimensions) hints.get(EncodeHintType.PDF417_DIMENSIONS);
      encoder.setDimensions(dimensions.getMaxCols(),
                            dimensions.getMinCols(),
                            dimensions.getMaxRows(),
                            dimensions.getMinRows());
    }
    if (hints.containsKey(EncodeHintType.MARGIN)) {
      margin = ((Number) hints.get(EncodeHintType.MARGIN)).intValue();
    }
    if (hints.containsKey(EncodeHintType.CHARACTER_SET)) {
      String encoding = (String) hints.get(EncodeHintType.CHARACTER_SET);
      encoder.setEncoding(Charset.forName(encoding));
    }
  }

  return bitMatrixFromEncoder(encoder, contents, width, height, margin);
}
项目:Android-Birdcopy-Application    文件:PDF417Writer.java   
/**
 * Takes encoder, accounts for width/height, and retrieves bit matrix
 */
private static BitMatrix bitMatrixFromEncoder(PDF417 encoder,
                                              String contents,
                                              int width,
                                              int height,
                                              int margin) throws WriterException {
  int errorCorrectionLevel = 2;
  encoder.generateBarcodeLogic(contents, errorCorrectionLevel);

  int lineThickness = 2;
  int aspectRatio = 4;
  byte[][] originalScale = encoder.getBarcodeMatrix().getScaledMatrix(lineThickness, aspectRatio * lineThickness);
  boolean rotated = false;
  if ((height > width) ^ (originalScale[0].length < originalScale.length)) {
    originalScale = rotateArray(originalScale);
    rotated = true;
  }

  int scaleX = width / originalScale[0].length;
  int scaleY = height / originalScale.length;

  int scale;
  if (scaleX < scaleY) {
    scale = scaleX;
  } else {
    scale = scaleY;
  }

  if (scale > 1) {
    byte[][] scaledMatrix =
        encoder.getBarcodeMatrix().getScaledMatrix(scale * lineThickness, scale * aspectRatio * lineThickness);
    if (rotated) {
      scaledMatrix = rotateArray(scaledMatrix);
    }
    return bitMatrixFrombitArray(scaledMatrix, margin);
  }
  return bitMatrixFrombitArray(originalScale, margin);
}
项目:zxing-bsplus    文件:PDF417Writer.java   
/**
 * Takes encoder, accounts for width/height, and retrieves bit matrix
 */
private static BitMatrix bitMatrixFromEncoder(PDF417 encoder,
                                              String contents,
                                              int errorCorrectionLevel,
                                              int width,
                                              int height,
                                              int margin) throws WriterException {
  encoder.generateBarcodeLogic(contents, errorCorrectionLevel);

  int aspectRatio = 4;
  byte[][] originalScale = encoder.getBarcodeMatrix().getScaledMatrix(1, aspectRatio);
  boolean rotated = false;
  if ((height > width) ^ (originalScale[0].length < originalScale.length)) {
    originalScale = rotateArray(originalScale);
    rotated = true;
  }

  int scaleX = width / originalScale[0].length;
  int scaleY = height / originalScale.length;

  int scale;
  if (scaleX < scaleY) {
    scale = scaleX;
  } else {
    scale = scaleY;
  }

  if (scale > 1) {
    byte[][] scaledMatrix =
        encoder.getBarcodeMatrix().getScaledMatrix(scale, scale * aspectRatio);
    if (rotated) {
      scaledMatrix = rotateArray(scaledMatrix);
    }
    return bitMatrixFrombitArray(scaledMatrix, margin);
  }
  return bitMatrixFrombitArray(originalScale, margin);
}
项目:ZxingCore    文件:PDF417Writer.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        Map<EncodeHintType,?> hints) throws WriterException {
  if (format != BarcodeFormat.PDF_417) {
    throw new IllegalArgumentException("Can only encode PDF_417, but got " + format);
  }

  PDF417 encoder = new PDF417();

  if (hints != null) {
    if (hints.containsKey(EncodeHintType.PDF417_COMPACT)) {
      encoder.setCompact((Boolean) hints.get(EncodeHintType.PDF417_COMPACT));
    }
    if (hints.containsKey(EncodeHintType.PDF417_COMPACTION)) {
      encoder.setCompaction((Compaction) hints.get(EncodeHintType.PDF417_COMPACTION));
    }
    if (hints.containsKey(EncodeHintType.PDF417_DIMENSIONS)) {
      Dimensions dimensions = (Dimensions) hints.get(EncodeHintType.PDF417_DIMENSIONS);
      encoder.setDimensions(dimensions.getMaxCols(),
                            dimensions.getMinCols(),
                            dimensions.getMaxRows(),
                            dimensions.getMinRows());
    }
  }

  return bitMatrixFromEncoder(encoder, contents, width, height);
}
项目:ZxingCore    文件:PDF417Writer.java   
/**
 * Takes encoder, accounts for width/height, and retrieves bit matrix
 */
private static BitMatrix bitMatrixFromEncoder(PDF417 encoder,
                                              String contents,
                                              int width,
                                              int height) throws WriterException {
  int errorCorrectionLevel = 2;
  encoder.generateBarcodeLogic(contents, errorCorrectionLevel);

  int lineThickness = 2;
  int aspectRatio = 4;
  byte[][] originalScale = encoder.getBarcodeMatrix().getScaledMatrix(lineThickness, aspectRatio * lineThickness);
  boolean rotated = false;
  if ((height > width) ^ (originalScale[0].length < originalScale.length)) {
    originalScale = rotateArray(originalScale);
    rotated = true;
  }

  int scaleX = width / originalScale[0].length;
  int scaleY = height / originalScale.length;

  int scale;
  if (scaleX < scaleY) {
    scale = scaleX;
  } else {
    scale = scaleY;
  }

  if (scale > 1) {
    byte[][] scaledMatrix =
        encoder.getBarcodeMatrix().getScaledMatrix(scale * lineThickness, scale * aspectRatio * lineThickness);
    if (rotated) {
      scaledMatrix = rotateArray(scaledMatrix);
    }
    return bitMatrixFrombitArray(scaledMatrix);
  }
  return bitMatrixFrombitArray(originalScale);
}
项目:weex-3d-map    文件:PDF417Writer.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        Map<EncodeHintType,?> hints) throws WriterException {
  if (format != BarcodeFormat.PDF_417) {
    throw new IllegalArgumentException("Can only encode PDF_417, but got " + format);
  }

  PDF417 encoder = new PDF417();
  int margin = WHITE_SPACE;
  int errorCorrectionLevel = DEFAULT_ERROR_CORRECTION_LEVEL;

  if (hints != null) {
    if (hints.containsKey(EncodeHintType.PDF417_COMPACT)) {
      encoder.setCompact(Boolean.valueOf(hints.get(EncodeHintType.PDF417_COMPACT).toString()));
    }
    if (hints.containsKey(EncodeHintType.PDF417_COMPACTION)) {
      encoder.setCompaction(Compaction.valueOf(hints.get(EncodeHintType.PDF417_COMPACTION).toString()));
    }
    if (hints.containsKey(EncodeHintType.PDF417_DIMENSIONS)) {
      Dimensions dimensions = (Dimensions) hints.get(EncodeHintType.PDF417_DIMENSIONS);
      encoder.setDimensions(dimensions.getMaxCols(),
                            dimensions.getMinCols(),
                            dimensions.getMaxRows(),
                            dimensions.getMinRows());
    }
    if (hints.containsKey(EncodeHintType.MARGIN)) {
      margin = Integer.parseInt(hints.get(EncodeHintType.MARGIN).toString());
    }
    if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {
      errorCorrectionLevel = Integer.parseInt(hints.get(EncodeHintType.ERROR_CORRECTION).toString());
    }
    if (hints.containsKey(EncodeHintType.CHARACTER_SET)) {
      Charset encoding = Charset.forName(hints.get(EncodeHintType.CHARACTER_SET).toString());
      encoder.setEncoding(encoding);
    }
  }

  return bitMatrixFromEncoder(encoder, contents, errorCorrectionLevel, width, height, margin);
}
项目:PortraitZXing    文件:PDF417Writer.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        Map<EncodeHintType,?> hints) throws WriterException {
  if (format != BarcodeFormat.PDF_417) {
    throw new IllegalArgumentException("Can only encode PDF_417, but got " + format);
  }

  PDF417 encoder = new PDF417();
  int margin = WHITE_SPACE;
  int errorCorrectionLevel = DEFAULT_ERROR_CORRECTION_LEVEL;

  if (hints != null) {
    if (hints.containsKey(EncodeHintType.PDF417_COMPACT)) {
      encoder.setCompact(Boolean.valueOf(hints.get(EncodeHintType.PDF417_COMPACT).toString()));
    }
    if (hints.containsKey(EncodeHintType.PDF417_COMPACTION)) {
      encoder.setCompaction(Compaction.valueOf(hints.get(EncodeHintType.PDF417_COMPACTION).toString()));
    }
    if (hints.containsKey(EncodeHintType.PDF417_DIMENSIONS)) {
      Dimensions dimensions = (Dimensions) hints.get(EncodeHintType.PDF417_DIMENSIONS);
      encoder.setDimensions(dimensions.getMaxCols(),
                            dimensions.getMinCols(),
                            dimensions.getMaxRows(),
                            dimensions.getMinRows());
    }
    if (hints.containsKey(EncodeHintType.MARGIN)) {
      margin = Integer.parseInt(hints.get(EncodeHintType.MARGIN).toString());
    }
    if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {
      errorCorrectionLevel = Integer.parseInt(hints.get(EncodeHintType.ERROR_CORRECTION).toString());
    }
    if (hints.containsKey(EncodeHintType.CHARACTER_SET)) {
      Charset encoding = Charset.forName(hints.get(EncodeHintType.CHARACTER_SET).toString());
      encoder.setEncoding(encoding);
    }
  }

  return bitMatrixFromEncoder(encoder, contents, errorCorrectionLevel, width, height, margin);
}
项目:PortraitZXing    文件:PDF417Writer.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        Map<EncodeHintType,?> hints) throws WriterException {
  if (format != BarcodeFormat.PDF_417) {
    throw new IllegalArgumentException("Can only encode PDF_417, but got " + format);
  }

  PDF417 encoder = new PDF417();
  int margin = WHITE_SPACE;
  int errorCorrectionLevel = DEFAULT_ERROR_CORRECTION_LEVEL;

  if (hints != null) {
    if (hints.containsKey(EncodeHintType.PDF417_COMPACT)) {
      encoder.setCompact(Boolean.valueOf(hints.get(EncodeHintType.PDF417_COMPACT).toString()));
    }
    if (hints.containsKey(EncodeHintType.PDF417_COMPACTION)) {
      encoder.setCompaction(Compaction.valueOf(hints.get(EncodeHintType.PDF417_COMPACTION).toString()));
    }
    if (hints.containsKey(EncodeHintType.PDF417_DIMENSIONS)) {
      Dimensions dimensions = (Dimensions) hints.get(EncodeHintType.PDF417_DIMENSIONS);
      encoder.setDimensions(dimensions.getMaxCols(),
                            dimensions.getMinCols(),
                            dimensions.getMaxRows(),
                            dimensions.getMinRows());
    }
    if (hints.containsKey(EncodeHintType.MARGIN)) {
      margin = Integer.parseInt(hints.get(EncodeHintType.MARGIN).toString());
    }
    if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {
      errorCorrectionLevel = Integer.parseInt(hints.get(EncodeHintType.ERROR_CORRECTION).toString());
    }
    if (hints.containsKey(EncodeHintType.CHARACTER_SET)) {
      Charset encoding = Charset.forName(hints.get(EncodeHintType.CHARACTER_SET).toString());
      encoder.setEncoding(encoding);
    }
  }

  return bitMatrixFromEncoder(encoder, contents, errorCorrectionLevel, width, height, margin);
}
项目:event-app    文件:PDF417Writer.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        Map<EncodeHintType,?> hints) throws WriterException {
  if (format != BarcodeFormat.PDF_417) {
    throw new IllegalArgumentException("Can only encode PDF_417, but got " + format);
  }

  PDF417 encoder = new PDF417();
  int margin = WHITE_SPACE;
  int errorCorrectionLevel = DEFAULT_ERROR_CORRECTION_LEVEL;

  if (hints != null) {
    if (hints.containsKey(EncodeHintType.PDF417_COMPACT)) {
      encoder.setCompact(Boolean.valueOf(hints.get(EncodeHintType.PDF417_COMPACT).toString()));
    }
    if (hints.containsKey(EncodeHintType.PDF417_COMPACTION)) {
      encoder.setCompaction(Compaction.valueOf(hints.get(EncodeHintType.PDF417_COMPACTION).toString()));
    }
    if (hints.containsKey(EncodeHintType.PDF417_DIMENSIONS)) {
      Dimensions dimensions = (Dimensions) hints.get(EncodeHintType.PDF417_DIMENSIONS);
      encoder.setDimensions(dimensions.getMaxCols(),
                            dimensions.getMinCols(),
                            dimensions.getMaxRows(),
                            dimensions.getMinRows());
    }
    if (hints.containsKey(EncodeHintType.MARGIN)) {
      margin = Integer.parseInt(hints.get(EncodeHintType.MARGIN).toString());
    }
    if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {
      errorCorrectionLevel = Integer.parseInt(hints.get(EncodeHintType.ERROR_CORRECTION).toString());
    }
    if (hints.containsKey(EncodeHintType.CHARACTER_SET)) {
      Charset encoding = Charset.forName(hints.get(EncodeHintType.CHARACTER_SET).toString());
      encoder.setEncoding(encoding);
    }
  }

  return bitMatrixFromEncoder(encoder, contents, errorCorrectionLevel, width, height, margin);
}
项目:weex-analyzer-android    文件:PDF417Writer.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        Map<EncodeHintType,?> hints) throws WriterException {
  if (format != BarcodeFormat.PDF_417) {
    throw new IllegalArgumentException("Can only encode PDF_417, but got " + format);
  }

  PDF417 encoder = new PDF417();
  int margin = WHITE_SPACE;
  int errorCorrectionLevel = DEFAULT_ERROR_CORRECTION_LEVEL;

  if (hints != null) {
    if (hints.containsKey(EncodeHintType.PDF417_COMPACT)) {
      encoder.setCompact(Boolean.valueOf(hints.get(EncodeHintType.PDF417_COMPACT).toString()));
    }
    if (hints.containsKey(EncodeHintType.PDF417_COMPACTION)) {
      encoder.setCompaction(Compaction.valueOf(hints.get(EncodeHintType.PDF417_COMPACTION).toString()));
    }
    if (hints.containsKey(EncodeHintType.PDF417_DIMENSIONS)) {
      Dimensions dimensions = (Dimensions) hints.get(EncodeHintType.PDF417_DIMENSIONS);
      encoder.setDimensions(dimensions.getMaxCols(),
                            dimensions.getMinCols(),
                            dimensions.getMaxRows(),
                            dimensions.getMinRows());
    }
    if (hints.containsKey(EncodeHintType.MARGIN)) {
      margin = Integer.parseInt(hints.get(EncodeHintType.MARGIN).toString());
    }
    if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {
      errorCorrectionLevel = Integer.parseInt(hints.get(EncodeHintType.ERROR_CORRECTION).toString());
    }
    if (hints.containsKey(EncodeHintType.CHARACTER_SET)) {
      Charset encoding = Charset.forName(hints.get(EncodeHintType.CHARACTER_SET).toString());
      encoder.setEncoding(encoding);
    }
  }

  return bitMatrixFromEncoder(encoder, contents, errorCorrectionLevel, width, height, margin);
}
项目:weex-3d-map    文件:PDF417Writer.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        Map<EncodeHintType,?> hints) throws WriterException {
  if (format != BarcodeFormat.PDF_417) {
    throw new IllegalArgumentException("Can only encode PDF_417, but got " + format);
  }

  PDF417 encoder = new PDF417();
  int margin = WHITE_SPACE;
  int errorCorrectionLevel = DEFAULT_ERROR_CORRECTION_LEVEL;

  if (hints != null) {
    if (hints.containsKey(EncodeHintType.PDF417_COMPACT)) {
      encoder.setCompact(Boolean.valueOf(hints.get(EncodeHintType.PDF417_COMPACT).toString()));
    }
    if (hints.containsKey(EncodeHintType.PDF417_COMPACTION)) {
      encoder.setCompaction(Compaction.valueOf(hints.get(EncodeHintType.PDF417_COMPACTION).toString()));
    }
    if (hints.containsKey(EncodeHintType.PDF417_DIMENSIONS)) {
      Dimensions dimensions = (Dimensions) hints.get(EncodeHintType.PDF417_DIMENSIONS);
      encoder.setDimensions(dimensions.getMaxCols(),
                            dimensions.getMinCols(),
                            dimensions.getMaxRows(),
                            dimensions.getMinRows());
    }
    if (hints.containsKey(EncodeHintType.MARGIN)) {
      margin = Integer.parseInt(hints.get(EncodeHintType.MARGIN).toString());
    }
    if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {
      errorCorrectionLevel = Integer.parseInt(hints.get(EncodeHintType.ERROR_CORRECTION).toString());
    }
    if (hints.containsKey(EncodeHintType.CHARACTER_SET)) {
      Charset encoding = Charset.forName(hints.get(EncodeHintType.CHARACTER_SET).toString());
      encoder.setEncoding(encoding);
    }
  }

  return bitMatrixFromEncoder(encoder, contents, errorCorrectionLevel, width, height, margin);
}
项目:Weex-TestDemo    文件:PDF417Writer.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        Map<EncodeHintType,?> hints) throws WriterException {
  if (format != BarcodeFormat.PDF_417) {
    throw new IllegalArgumentException("Can only encode PDF_417, but got " + format);
  }

  PDF417 encoder = new PDF417();
  int margin = WHITE_SPACE;
  int errorCorrectionLevel = DEFAULT_ERROR_CORRECTION_LEVEL;

  if (hints != null) {
    if (hints.containsKey(EncodeHintType.PDF417_COMPACT)) {
      encoder.setCompact(Boolean.valueOf(hints.get(EncodeHintType.PDF417_COMPACT).toString()));
    }
    if (hints.containsKey(EncodeHintType.PDF417_COMPACTION)) {
      encoder.setCompaction(Compaction.valueOf(hints.get(EncodeHintType.PDF417_COMPACTION).toString()));
    }
    if (hints.containsKey(EncodeHintType.PDF417_DIMENSIONS)) {
      Dimensions dimensions = (Dimensions) hints.get(EncodeHintType.PDF417_DIMENSIONS);
      encoder.setDimensions(dimensions.getMaxCols(),
                            dimensions.getMinCols(),
                            dimensions.getMaxRows(),
                            dimensions.getMinRows());
    }
    if (hints.containsKey(EncodeHintType.MARGIN)) {
      margin = Integer.parseInt(hints.get(EncodeHintType.MARGIN).toString());
    }
    if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {
      errorCorrectionLevel = Integer.parseInt(hints.get(EncodeHintType.ERROR_CORRECTION).toString());
    }
    if (hints.containsKey(EncodeHintType.CHARACTER_SET)) {
      Charset encoding = Charset.forName(hints.get(EncodeHintType.CHARACTER_SET).toString());
      encoder.setEncoding(encoding);
    }
  }

  return bitMatrixFromEncoder(encoder, contents, errorCorrectionLevel, width, height, margin);
}
项目:Cardstore    文件:PDF417Writer.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        Map<EncodeHintType, ?> hints) throws WriterException {
  if (format != BarcodeFormat.PDF_417) {
    throw new IllegalArgumentException("Can only encode PDF_417, but got " + format);
  }

  PDF417 encoder = new PDF417();
  int margin = WHITE_SPACE;
  int errorCorrectionLevel = DEFAULT_ERROR_CORRECTION_LEVEL;

  if (hints != null) {
    if (hints.containsKey(EncodeHintType.PDF417_COMPACT)) {
      encoder.setCompact(Boolean.valueOf(hints.get(EncodeHintType.PDF417_COMPACT).toString()));
    }
    if (hints.containsKey(EncodeHintType.PDF417_COMPACTION)) {
      encoder.setCompaction(Compaction.valueOf(hints.get(EncodeHintType.PDF417_COMPACTION).toString()));
    }
    if (hints.containsKey(EncodeHintType.PDF417_DIMENSIONS)) {
      Dimensions dimensions = (Dimensions) hints.get(EncodeHintType.PDF417_DIMENSIONS);
      encoder.setDimensions(dimensions.getMaxCols(),
              dimensions.getMinCols(),
              dimensions.getMaxRows(),
              dimensions.getMinRows());
    }
    if (hints.containsKey(EncodeHintType.MARGIN)) {
      margin = Integer.parseInt(hints.get(EncodeHintType.MARGIN).toString());
    }
    if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {
      errorCorrectionLevel = Integer.parseInt(hints.get(EncodeHintType.ERROR_CORRECTION).toString());
    }
    if (hints.containsKey(EncodeHintType.CHARACTER_SET)) {
      Charset encoding = Charset.forName(hints.get(EncodeHintType.CHARACTER_SET).toString());
      encoder.setEncoding(encoding);
    }
  }

  return bitMatrixFromEncoder(encoder, contents, errorCorrectionLevel, width, height, margin);
}
项目:weex    文件:PDF417Writer.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        Map<EncodeHintType,?> hints) throws WriterException {
  if (format != BarcodeFormat.PDF_417) {
    throw new IllegalArgumentException("Can only encode PDF_417, but got " + format);
  }

  PDF417 encoder = new PDF417();
  int margin = WHITE_SPACE;
  int errorCorrectionLevel = DEFAULT_ERROR_CORRECTION_LEVEL;

  if (hints != null) {
    if (hints.containsKey(EncodeHintType.PDF417_COMPACT)) {
      encoder.setCompact(Boolean.valueOf(hints.get(EncodeHintType.PDF417_COMPACT).toString()));
    }
    if (hints.containsKey(EncodeHintType.PDF417_COMPACTION)) {
      encoder.setCompaction(Compaction.valueOf(hints.get(EncodeHintType.PDF417_COMPACTION).toString()));
    }
    if (hints.containsKey(EncodeHintType.PDF417_DIMENSIONS)) {
      Dimensions dimensions = (Dimensions) hints.get(EncodeHintType.PDF417_DIMENSIONS);
      encoder.setDimensions(dimensions.getMaxCols(),
                            dimensions.getMinCols(),
                            dimensions.getMaxRows(),
                            dimensions.getMinRows());
    }
    if (hints.containsKey(EncodeHintType.MARGIN)) {
      margin = Integer.parseInt(hints.get(EncodeHintType.MARGIN).toString());
    }
    if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {
      errorCorrectionLevel = Integer.parseInt(hints.get(EncodeHintType.ERROR_CORRECTION).toString());
    }
    if (hints.containsKey(EncodeHintType.CHARACTER_SET)) {
      Charset encoding = Charset.forName(hints.get(EncodeHintType.CHARACTER_SET).toString());
      encoder.setEncoding(encoding);
    }
  }

  return bitMatrixFromEncoder(encoder, contents, errorCorrectionLevel, width, height, margin);
}
项目:zxing-bsplus    文件:PDF417Writer.java   
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        Map<EncodeHintType,?> hints) throws WriterException {
  if (format != BarcodeFormat.PDF_417) {
    throw new IllegalArgumentException("Can only encode PDF_417, but got " + format);
  }

  PDF417 encoder = new PDF417();
  int margin = WHITE_SPACE;
  int errorCorrectionLevel = DEFAULT_ERROR_CORRECTION_LEVEL;

  if (hints != null) {
    if (hints.containsKey(EncodeHintType.PDF417_COMPACT)) {
      encoder.setCompact(Boolean.valueOf(hints.get(EncodeHintType.PDF417_COMPACT).toString()));
    }
    if (hints.containsKey(EncodeHintType.PDF417_COMPACTION)) {
      encoder.setCompaction(Compaction.valueOf(hints.get(EncodeHintType.PDF417_COMPACTION).toString()));
    }
    if (hints.containsKey(EncodeHintType.PDF417_DIMENSIONS)) {
      Dimensions dimensions = (Dimensions) hints.get(EncodeHintType.PDF417_DIMENSIONS);
      encoder.setDimensions(dimensions.getMaxCols(),
                            dimensions.getMinCols(),
                            dimensions.getMaxRows(),
                            dimensions.getMinRows());
    }
    if (hints.containsKey(EncodeHintType.MARGIN)) {
      margin = Integer.parseInt(hints.get(EncodeHintType.MARGIN).toString());
    }
    if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {
      errorCorrectionLevel = Integer.parseInt(hints.get(EncodeHintType.ERROR_CORRECTION).toString());
    }
    if (hints.containsKey(EncodeHintType.CHARACTER_SET)) {
      Charset encoding = Charset.forName(hints.get(EncodeHintType.CHARACTER_SET).toString());
      encoder.setEncoding(encoding);
    }
  }

  return bitMatrixFromEncoder(encoder, contents, errorCorrectionLevel, width, height, margin);
}