Package com.google.zxing

Examples of com.google.zxing.MultiFormatWriter


        throws WriterException, UnsupportedEncodingException, IOException, TypeConversionException,
        NoTypeConversionAvailableException {
        
        final String payload = ExchangeHelper
                .convertToMandatoryType(exchange, String.class, graph);
        final MultiFormatWriter writer = new MultiFormatWriter();

        // set values
        final String type = this.params.getType().toString();
       
        // create code image 
        final BitMatrix matrix = writer.encode(
                payload,
                this.params.getFormat(),
                this.params.getWidth(),
                this.params.getHeight(),
                writerHintMap);
View Full Code Here


            public void run() {

              FileConnection fconn = null;
              try{
                  MultiFormatWriter writer = new MultiFormatWriter();

                  int width = 50;
                  int height = 50;
                  BarcodeFormat format = BarcodeFormat.QR_CODE;
                  Hashtable hints = new Hashtable(2);
                  String filePath = "file:///SDCard/";
                  String fileName = ""+(new Date()).getTime();
                  String fileExtension = "png";
                 
                  if(options != null){
                    Object  widthObj =options.getField("width");
                    if(widthObj != UNDEFINED){
                      width =((Integer)widthObj).intValue();
                    }
                   
                    Object heightObj = options.getField("height");
                    if(heightObj != UNDEFINED){
                      height = ((Integer)heightObj).intValue();
                    }
                   
                    Object formatObj = options.getField("format");
                    if(formatObj != UNDEFINED){
                      format = BarcodeFormat.valueOf(((String)formatObj).toUpperCase());
                    }                   
                   
                    //Hints
                    Object charSetObj = options.getField("characterSet");
                    if(charSetObj != UNDEFINED){
                      hints.put(EncodeHintType.CHARACTER_SET, (String)charSetObj);
                    }
                    Object errorCorrectionObj = options.getField("errorCorrection");
                    if(errorCorrectionObj != UNDEFINED){
                      hints.put(EncodeHintType.ERROR_CORRECTION, (Integer)errorCorrectionObj);
                    }
                   
                    Object filePathObj = options.getField("filePath");
                    if(filePathObj != UNDEFINED){
                      String filePathOrig = (String)filePathObj;
                      fileExtension = filePathOrig.substring(filePathOrig.lastIndexOf('.')+1);
                      fileName = filePathOrig.substring(filePathOrig.lastIndexOf('/')+1,filePathOrig.lastIndexOf('.'));
                      filePath = filePathOrig.substring(0, filePathOrig.lastIndexOf('/'));
                     
                      boolean validExtension = false;
                      for( int i =0; i< ALLOWED_EXTENSIONS.length;i++){
                        validExtension |= fileExtension.equals(ALLOWED_EXTENSIONS[i]);
                      }
                      if(!validExtension){
                        fileExtension = "png";
                      }
                    }                                                         
                   
                  }
                 
                  ByteMatrix bm;                 
                  try{
                     bm = writer.encode(contents, format, width, height,hints);
                  }catch(ClassCastException cce){
                    throw new Exception("ZXing Barcode Writer FAILURE - try different paramteres and pray");
                  }
                  //Bitmap b = BarcodeBitmap.createBitmap(bm,0);
                  Bitmap b = new Bitmap(width,height);
View Full Code Here

        throws WriterException, UnsupportedEncodingException, IOException, TypeConversionException,
        NoTypeConversionAvailableException {
        
        final String payload = ExchangeHelper
                .convertToMandatoryType(exchange, String.class, graph);
        final MultiFormatWriter writer = new MultiFormatWriter();

        // set values
        final String type = this.params.getType().toString();
       
        // create code image 
        final BitMatrix matrix = writer.encode(
                payload,
                this.params.getFormat(),
                this.params.getWidth(),
                this.params.getHeight(),
                writerHintMap);
View Full Code Here

        BitMatrix matrix = null;
        int h = size;
        int w = size;
        int barsize = -1;
        Writer writer = new MultiFormatWriter();
        try {
            Map<EncodeHintType, Object> hints = new EnumMap<EncodeHintType, Object>(EncodeHintType.class);
            hints.put(EncodeHintType.CHARACTER_SET, "ISO-8859-1");
            QRCode code = Encoder.encode(paymentString, ErrorCorrectionLevel.M, hints);
            hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M);
            barsize = size / (code.getMatrix().getWidth() + 8);
            matrix = writer.encode(paymentString, com.google.zxing.BarcodeFormat.QR_CODE, w, h, hints);
        } catch (com.google.zxing.WriterException e) {
            System.out.println(e.getMessage());
        }

        if (matrix == null || barsize < 0) {
View Full Code Here

TOP

Related Classes of com.google.zxing.MultiFormatWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.