private static void addCharacterSet(int value_Renamed, System.String encodingName) { CharacterSetECI eci = new CharacterSetECI(value_Renamed, encodingName); VALUE_TO_ECI[(System.Int32)value_Renamed] = eci; // can't use valueOf NAME_TO_ECI[encodingName] = eci; }
private static void addCharacterSet(int value_Renamed, System.String[] encodingNames) { CharacterSetECI eci = new CharacterSetECI(value_Renamed, encodingNames[0]); VALUE_TO_ECI[(System.Int32) value_Renamed] = eci; // can't use valueOf for (int i = 0; i < encodingNames.Length; i++) { NAME_TO_ECI[encodingNames[i]] = eci; } }
public static void encode(System.String content, ErrorCorrectionLevel ecLevel, System.Collections.Hashtable hints, QRCode qrCode) { System.String encoding = hints == null?null:(System.String) hints[EncodeHintType.CHARACTER_SET]; if (encoding == null) { encoding = DEFAULT_BYTE_MODE_ENCODING; } // Step 1: Choose the mode (encoding). Mode mode = chooseMode(content, encoding); // Step 2: Append "bytes" into "dataBits" in appropriate encoding. BitVector dataBits = new BitVector(); appendBytes(content, mode, dataBits, encoding); // Step 3: Initialize QR code that can contain "dataBits". int numInputBytes = dataBits.sizeInBytes(); initQRCode(numInputBytes, ecLevel, mode, qrCode); // Step 4: Build another bit vector that contains header and data. BitVector headerAndDataBits = new BitVector(); // Step 4.5: Append ECI message if applicable if (mode == Mode.BYTE && !DEFAULT_BYTE_MODE_ENCODING.Equals(encoding)) { CharacterSetECI eci = CharacterSetECI.getCharacterSetECIByName(encoding); if (eci != null) { appendECI(eci, headerAndDataBits); } } appendModeInfo(mode, headerAndDataBits); int numLetters = mode.Equals(Mode.BYTE)?dataBits.sizeInBytes():content.Length; appendLengthInfo(numLetters, qrCode.Version, mode, headerAndDataBits); headerAndDataBits.appendBitVector(dataBits); // Step 5: Terminate the bits properly. terminateBits(qrCode.NumDataBytes, headerAndDataBits); // Step 6: Interleave data bits with error correction code. BitVector finalBits = new BitVector(); interleaveWithECBytes(headerAndDataBits, qrCode.NumTotalBytes, qrCode.NumDataBytes, qrCode.NumRSBlocks, finalBits); // Step 7: Choose the mask pattern and set to "qrCode". ByteMatrix matrix = new ByteMatrix(qrCode.MatrixWidth, qrCode.MatrixWidth); qrCode.MaskPattern = chooseMaskPattern(finalBits, qrCode.ECLevel, qrCode.Version, matrix); // Step 8. Build the matrix and set it to "qrCode". MatrixUtil.buildMatrix(finalBits, qrCode.ECLevel, qrCode.Version, qrCode.MaskPattern, matrix); qrCode.Matrix = matrix; // Step 9. Make sure we have a valid QR Code. if (!qrCode.Valid) { throw new WriterException("Invalid QR code: " + qrCode.ToString()); } }
private static void addCharacterSet(int value_Renamed, System.String[] encodingNames) { CharacterSetECI eci = new CharacterSetECI(value_Renamed, encodingNames[0]); VALUE_TO_ECI[(System.Int32)value_Renamed] = eci; // can't use valueOf for (int i = 0; i < encodingNames.Length; i++) { NAME_TO_ECI[encodingNames[i]] = eci; } }
/// <param name="value">ECI value /// </param> /// <returns> {@link ECI} representing ECI of given value, or null if it is legal but unsupported /// </returns> /// <throws> IllegalArgumentException if ECI value is invalid </throws> public static ECI getECIByValue(int value_Renamed) { if (value_Renamed < 0 || value_Renamed > 999999) { throw new System.ArgumentException("Bad ECI value: " + value_Renamed); } if (value_Renamed < 900) { // Character set ECIs use 000000 - 000899 return(CharacterSetECI.getCharacterSetECIByValue(value_Renamed)); } return(null); }
private static void addCharacterSet(int value_Renamed, System.String encodingName) { CharacterSetECI eci = new CharacterSetECI(value_Renamed, encodingName); VALUE_TO_ECI[(System.Int32) value_Renamed] = eci; // can't use valueOf NAME_TO_ECI[encodingName] = eci; }
private static void appendECI(CharacterSetECI eci, BitVector bits) { bits.appendBits(Mode.ECI.Bits, 4); // This is correct for values up to 127, which is all we need now. bits.appendBits(eci.Value, 8); }