QR codes image generator in java (open source but

2019-01-21 04:52发布

I'm seeking an open source QR codes image generator component in java (J2SE), but the open source licence mustn't be a GPL licence (needs to be included in a close source project).

BTW, i can't access the web from the project so no Google API.

3条回答
我命由我不由天
2楼-- · 2019-01-21 05:25

MatrixToImageWriter uses BitMatrix, not ByteMatrix as returned by QRCode.getMatrix. by looking at android sourcecode, I found the following proof of concept solution:

    try {
        MultiFormatWriter writer = new MultiFormatWriter();    
        Hashtable hints = new Hashtable();
        hints.put( EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.Q );            
        MatrixToImageWriter.writeToFile( writer.encode( "hello world", BarcodeFormat.QR_CODE, 800, 800, hints ),
                                         "png", new File( "/tmp/qrcode.png" ) );
    } catch ( Exception e ) {
        System.out.println( "failure: " + e );
    }

btw imposing Hashtable in API is not clean. please use Map. not many people still use Hashtable anyway, you should almost always use HashMap instead (except a few use cases).

查看更多
何必那么认真
3楼-- · 2019-01-21 05:33

ZXing is is an open-source, multi-format 1D/2D barcode image processing library implemented in Java. It is released under the The Apache License, so it allows use of the source code for the development of proprietary software as well as free and open source software.

查看更多
姐就是有狂的资本
4楼-- · 2019-01-21 05:35

Mercer - no, there is an encoder in the library too. com.google.zxing.qrcode.encoder. We provide that in addition to an example web app using Google Chart APIs

查看更多
登录 后发表回答