Coder Social home page Coder Social logo

qrgen's People

Contributors

arielcabib avatar atomfrede avatar avalax avatar bitdeli-chef avatar degendra avatar diegosouzapb avatar dubiao avatar fadils avatar fleker avatar flurdy avatar gmarizy avatar jitpack-io avatar kenglxn avatar killme2008 avatar lonzak avatar paolorotolo avatar tannyll avatar tr00per avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qrgen's Issues

Open Source Licence

Hello, could you add an open source license so others can use and improve your project easily?

Thank you!

No vector formats available

no vector graphic formats EPS or SVG available.
I want to have QR image with vector format for better print quality. Something like:
QRCode.from("Hello World").to(ImageType.SVG).withSize(250, 250).file();

Update Android library in repo

Please update Android library in repo, I have used it from maven repo, but QRCode class doesn't have all required methods, that are present in you git repo by the way, so I have to extend AbstractQRCode class.
Methods like withSize, to are not implemented.
Current QRCode class content if following

import android.graphics.Bitmap;

import com.google.zxing.EncodeHintType;
import com.google.zxing.WriterException;
import com.google.zxing.qrcode.QRCodeWriter;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;

import net.glxn.qrgen.core.AbstractQRCode;
import net.glxn.qrgen.core.exception.QRGenerationException;
import net.glxn.qrgen.core.image.ImageType;
import net.glxn.qrgen.core.scheme.VCard;

import java.io.File;
import java.io.IOException;
import java.io.OutputStream;

public class QRCode extends AbstractQRCode {

    protected final String text;

    protected QRCode(String text) {
        this.text = text;
        qrWriter = new QRCodeWriter();
    }

    /**
     * Create a QR code from the given text. <br/>
     * <br/>
     * <p/>
     * There is a size limitation to how much you can put into a QR code. This
     * has been tested to work with up to a length of 2950 characters.<br/>
     * <br/>
     * <p/>
     * The QRCode will have the following defaults: <br/>
     * {size: 100x100}<br/>
     * {imageType:PNG} <br/>
     * <br/>
     * <p/>
     * Both size and imageType can be overridden: <br/>
     * Image type override is done by calling
     * {@link AbstractQRCode#to(net.glxn.qrgen.core.image.ImageType)} e.g.
     * QRCode.from("hello world").to(JPG) <br/>
     * Size override is done by calling {@link AbstractQRCode#withSize} e.g.
     * QRCode.from("hello world").to(JPG).withSize(125, 125) <br/>
     *
     * @param text the text to encode to a new QRCode, this may fail if the text
     *             is too large. <br/>
     * @return the QRCode object <br/>
     */
    public static QRCode from(String text) {
        return new QRCode(text);
    }

    /**
     * Creates a a QR Code from the given {@link VCard}.
     * <p/>
     * The QRCode will have the following defaults: <br/>
     * {size: 100x100}<br/>
     * {imageType:PNG} <br/>
     * <br/>
     *
     * @param vcard the vcard to encode as QRCode
     * @return the QRCode object
     */
    public static QRCode from(VCard vcard) {
        return new QRCode(vcard.toString());
    }

    /**
     * Overrides the imageType from its default {@link net.glxn.qrgen.core.image.ImageType#PNG}
     *
     * @param imageType the {@link net.glxn.qrgen.core.image.ImageType} you would like the resulting QR to be
     * @return the current QRCode object
     */
    public QRCode to(ImageType imageType) {
        this.imageType = imageType;
        return this;
    }

    /**
     * Overrides the size of the qr from its default 125x125
     *
     * @param width  the width in pixels
     * @param height the height in pixels
     * @return the current QRCode object
     */
    public QRCode withSize(int width, int height) {
        this.width = width;
        this.height = height;
        return this;
    }

    /**
     * Overrides the default charset by supplying a {@link com.google.zxing.EncodeHintType#CHARACTER_SET} hint to {@link
     * com.google.zxing.qrcode.QRCodeWriter#encode}
     *
     * @return the current QRCode object
     */
    public QRCode withCharset(String charset) {
        return withHint(EncodeHintType.CHARACTER_SET, charset);
    }

    /**
     * Overrides the default error correction by supplying a {@link com.google.zxing.EncodeHintType#ERROR_CORRECTION} hint to
     * {@link com.google.zxing.qrcode.QRCodeWriter#encode}
     *
     * @return the current QRCode object
     */
    public QRCode withErrorCorrection(ErrorCorrectionLevel level) {
        return withHint(EncodeHintType.ERROR_CORRECTION, level);
    }

    /**
     * Sets hint to {@link com.google.zxing.qrcode.QRCodeWriter#encode}
     *
     * @return the current QRCode object
     */
    public QRCode withHint(EncodeHintType hintType, Object value) {
        hints.put(hintType, value);
        return this;
    }

    /**
     * Returns a {@link android.graphics.Bitmap} without creating a {@link java.io.File} first.
     *
     * @return {@link android.graphics.Bitmap} of this QRCode
     */
    public Bitmap bitmap() {
        try {
            return MatrixToImageWriter.toBitmap(createMatrix(text));
        } catch (WriterException e) {
            throw new QRGenerationException("Failed to create QR image from text due to underlying exception", e);
        }
    }

    @Override
    public File file() {
        File file;
        try {
            file = createTempFile();
            MatrixToImageWriter.writeToFile(createMatrix(text), imageType.toString(), file);
        } catch (Exception e) {
            throw new QRGenerationException("Failed to create QR image from text due to underlying exception", e);
        }

        return file;
    }

    @Override
    public File file(String name) {
        File file;
        try {
            file = createTempFile(name);
            MatrixToImageWriter.writeToFile(createMatrix(text), imageType.toString(), file);
        } catch (Exception e) {
            throw new QRGenerationException("Failed to create QR image from text due to underlying exception", e);
        }

        return file;
    }

    @Override
    protected void writeToStream(OutputStream stream) throws IOException, WriterException {
        MatrixToImageWriter.writeToStream(createMatrix(text), imageType.toString(), stream);
    }
}

Charset not specified

It should be possible to specify the desired charset. I have special chars in the text I use to generate the QRCode and they are badly encoded when I read the genrated QRCode. I would suggest to use UTF-8 by default, to avoid this.

Exception in Rendring

GMPM: getGoogleAppId failed with status: 10
GMPM: Uploading is not possible. App measurement disabled
AndroidRuntime: FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: net.glxn.qrgen.android.QRCode

image overlay

Could you please adds a image overlay to a qrcode?

Copyright holder?

Hey there,

We have used QRGen in a program we're developing. It's great and we really appreciate you sharing your work. We'd like to attribute your hard work to you by including a copyright notice in our documentation. However, we haven't been able to find one in the source or on the site. Who is the copyright holder and what is the year of the copyright?

Is this right?

Copyright (C) 2013 Frederik Hahne, Ken Gullaksen, Bitdeli Chef

Thanks in advance!

withColor();

What about withColor() method in android?
why it's only available in java se version, and when it will be available in android?!

Generating QR code

Hi.
I imported android-2.0-20140713.143342-8.jar to my project from "https://oss.sonatype.org/content/repositories/snapshots/net/glxn/qrgen/android/2.0-SNAPSHOT/" and then according to your README.md usage, i wrote this code on my activity:
File file = QRCode.from("Hello World").file();
// override the image type to be JPG
QRCode.from("Hello World").to(ImageType.JPG).file();
QRCode.from("Hello World").file("QRCode");

However, it crashed the application. the logcat stated that "java.lang.NoClassDefFoundError: com.google.zxing.qrcode.QRCodeWriter." May i know how should i solve this?

Dimension behaves unpropotional

The generated QR code never covers the complete image because the generator always adds some border around it. One issue is that the dimension of the QR code does behave propotional to the dimension of the target image including the border. The problem is when you change the size of the image by one pixel the size of the QR code gets increased by 10 pixel wheareas the border size gets decreased by 9 pixels. This is not propotional to a change by one pixel.

A reproducible example where the actual QR code gets a lot smaller by changeing the image size by only one pixel:

  1. generate a QR code with the dimension 110x110 pixel
  2. generate a QR code with the dimension 111x111 pixel

The difference is big:
Image example

Release v 2.0

I need to get around to doing this soon.
When 2.0 is released, remember to update the Readme as well.

failed to find: net.glxn.qrgen:android:2.0-SNAPSHOT

Using Android Studio adding

dependencies {
compile ("net.glxn.qrgen:android:2.0-SNAPSHOT")
compile fileTree(dir: 'libs', include: ['*.jar'])
}

to build.gradle.

Error:

failed to find: net.glxn.qrgen:android:2.0-SNAPSHOT

What am I doing wrong? Please help.

QRCode.stream() cannot be used on AppEngine

Calling QRCode.stream() fails on Google AppEngine. The BufferedImage used by the unterlying zxing library is not whitelisted (see https://developers.google.com/appengine/docs/java/jrewhitelist). As a result, the qrgen library cannot be used in GAE applications at the moment. Are there any plans to change the library so that it can be used on App Engine?

REST-based QR code generators exist. But to reduce latency I would prefer generating the code inside of my GAE app (instead of talking to a REST service).

[INFO] Caused by: java.lang.NoClassDefFoundError: java.awt.image.BufferedImage is a restricted class. Please see the Google App Engine developer's guide for more details.
[INFO] at com.google.appengine.tools.development.agent.runtime.Runtime.reject(Runtime.java:51)
[INFO] at com.google.zxing.client.j2se.MatrixToImageWriter.toBufferedImage(MatrixToImageWriter.java:55)
[INFO] at com.google.zxing.client.j2se.MatrixToImageWriter.writeToStream(MatrixToImageWriter.java:117)
[INFO] at com.google.zxing.client.j2se.MatrixToImageWriter.writeToStream(MatrixToImageWriter.java:109)
[INFO] at net.glxn.qrgen.QRCode.writeToStream(QRCode.java:202)
[INFO] at net.glxn.qrgen.QRCode.stream(QRCode.java:180)

fix VCard newline and charset

Come to think of it, the fix in #14 probably is not a good idea, as I believe it would override charset hint if supplied. I also think the VCard should use System.lineSeparator() instead of \n to work properly across platforms.

problem with bitmap

I can't use any method in the library with the bitmap, only the given example in read me works, but if i want to add some methods like withCharset() or withWidth() it's just give me error!

for example:
final Bitmap bm = QRCode.from(et.getText().toString()).bitmap(); <-- That's works!

final Bitmap bm = QRCode.from(et.getText().toString()).withSize(600, 600).withCharset("UTF-8").bitmap(); <-- Not working!

Also the withColor() method don't work in general!

Am new in programming actually and don't know how to use that or is this is a serious issue or not!

support for other QR types

Its have only two types supported now (Text and VCard). If I open this page
http://goqr.me/#t=call
on the point 1. its have 9 types: Call, URL, SMS, WIFI, Location.. is missing
I suppose that all types are string formatted with some tags like VCard.toString() but I cant find info for this?
I have found WiFi schema:
core/src/test/java/net/glxn/qrgen/core/scheme/WifiTest.java

Do you have schema for Call ? (phone number)
I have found here http://sixrevisions.com/web-development/qr-codes-uri-schemes/
tel:

this is very helpful
https://github.com/zxing/zxing/blob/master/core/src/test/java/com/google/zxing/client/result/ParsedReaderResultTestCase.java

it will be good if its have info in README for the different schema types. I can provide PR or this is better to be set with Enum before Text?

Bitmap is the prefered format for android

It's not a bug but a suggestion. Could QRGen output bitmap in addition of JPG, GIF and PNG ? Android need bitmap format for display. Just an idea, qrgen-android-exemple could change from:

File f = QRCode.from("https://github.com/kenglxn/QRGen").to(ImageType.JPG).file();
Bitmap myBitmap = BitmapFactory.decodeFile(f.getAbsolutePath());
ImageView myImage = (ImageView) findViewById(R.id.imageView);
myImage.setImageBitmap(myBitmap);

to:

Bitmap myBitmap = QRCode.from("https://github.com/kenglxn/QRGen").bitmap();
ImageView myImage = (ImageView) findViewById(R.id.imageView);
myImage.setImageBitmap(myBitmap);

Since QRGen already produce the bitmap internally, it will avoid to compress it in PNG, then to put it on a file, then the BitmapFactory thing.

organize poms

make use of dependencyManagement and pluginManagement. All versions should be properties in the parent pom.

Java 6 is not supported?

Was getting the following error:

Caused by: java.lang.UnsupportedClassVersionError: net/glxn/qrgen/javase/QRCode : Unsupported major.minor version 51.0

add checkstyle plugin

Create a checkstyle that validates code formatting according to my Intellij IDEA settings

cannot resolve

I added compile 'com.github.kenglxn.QRGen:javase:2.2.0' to my android project. However, I ended up getting an error says "Failed to resolve github.kenglxn.QRGen:javase:2.2.0". Is there any other dependency should be added?

Compatibility with Google App Engine

I'm writing a web app with Google App Engine. I found your library and I'm very interested in using it to generate QR codes. However I have an exception because you're creating a temporary file when I use

File file = QRCode.from("Hello World").file();

It generate a net.glxn.qrgen.core.exception.QRGenerationException

Do u know how can I solve this issue?

java.lang.VerifyError: net/glxn/qrgen/android/QRCode

I use this to make bitmap

Bitmap qrCode = QRCode.from(macAddress).withSize(200, 200).bitmap();
imageView.setImageBitmap(qrCode);

but show error:

java.lang.VerifyError: net/glxn/qrgen/android/QRCode
    at com.bitmain.bmrobot.activity.MainActivity.onOptionsItemSelected(MainActivity.java:198)
    at android.app.Activity.onMenuItemSelected(Activity.java:2607)
    at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:408)
    at android.support.v7.app.AppCompatActivity.onMenuItemSelected(AppCompatActivity.java:198)
    at android.support.v7.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:107)
    at android.support.v7.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:107)
    at android.support.v7.app.ToolbarActionBar$2.onMenuItemClick(ToolbarActionBar.java:69)
    at android.support.v7.widget.Toolbar$1.onMenuItemClick(Toolbar.java:206)
    at android.support.v7.widget.ActionMenuView$MenuBuilderCallback.onMenuItemSelected(ActionMenuView.java:777)
    at android.support.v7.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:817)
    at android.support.v7.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:156)
    at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:964)
    at android.support.v7.view.menu.MenuPopup.onItemClick(MenuPopup.java:127)
    at android.widget.AdapterView.performItemClick(AdapterView.java:299)
    at android.widget.AbsListView.performItemClick(AbsListView.java:1115)
    at android.widget.AbsListView$PerformClick.run(AbsListView.java:2928)
    at android.widget.AbsListView$3.run(AbsListView.java:3691)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5028)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
    at dalvik.system.NativeStart.main(Native Method)

Invalid maven groupid

The groupid for your artifact in Maven seems to be com.github.kenglxn.QRGen. I know this is a minor thing but it took me some time to realize since in your documentation you state it as com.github.kenglxn.qrgen.

Cannot access repo

Try to use your library in my project.

build.gradle:

dependencies {
    ....
    compile 'com.github.kenglxn.QRGbuen:android:2.1.0'
    ....
}

When I buil my project I get error:

Error:Could not GET 'https://jitpack.io/com/github/kenglxn/QRGbuen/android/2.1.0/android-2.1.0.pom'. Received status code 401 from server: Repo not found or no access token provided

VCard force stop on android

VCard not working on SDK 10 gingerbread, forcebstop every time try to generate from it, NoSuchMethodException, I handled it but it's also not working, just give me the handled toast even the text fields not empty!

Execution failed for task ':app:transformClassesWithJarMergingForDebug'

I got a problem when I used two libraries of QR-Code (Ready and Generator QR-Code) in gradle

compile 'com.dlazaro66.qrcodereaderview:qrcodereaderview:1.0.0'
compile 'com.github.kenglxn.QRGen:android:2.1.0'

=================== Gradle ===============
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.dlazaro66.qrcodereaderview:qrcodereaderview:1.0.0'
compile 'com.github.kenglxn.QRGen:android:2.1.0'
}

========== Message after run project failed ===============
FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:transformClassesWithJarMergingForDebug'.

    com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/zxing/BarcodeFormat.class

Please fix this issue

QRCode white border

Hello,
Is it possible to remove the border created around the QRCode or change its size?
I can always crop it or manipulate the bitmap, but it would be nice to have a lib's method to do so.

Thanks.

ps: I'm using it for Android.

Readme Variable Issue

Update this line
QRCode.from("Hello World").to(ImageType.PNG).writeTo(outputStream);

to
QRCode.from("Hello World").to(ImageType.PNG).writeTo(stream);

because outputStream was never created.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.