Giter VIP home page Giter VIP logo

Comments (2)

srowen avatar srowen commented on September 25, 2024

I don't mind tightening up the very lenient check here: https://github.com/zxing/zxing/blob/master/core/src/main/java/com/google/zxing/client/result/EmailDoCoMoResultParser.java#L60
Feel free to propose something that maybe looks for at least something like a domain after "@"

The app itself can't be updated, but I think a conservative change to that logic is not bad

from zxing.

ANAGH1234 avatar ANAGH1234 commented on September 25, 2024

see this code-private int[] determineDimensions(int sourceCodeWords, int errorCorrectionCodeWords) throws WriterException {
float ratio = 0.0f;
int[] dimension = null;

int currentCols = minCols;
for (int cols = minCols; cols <= maxCols; cols++) {
    currentCols = cols;
    int rows = calculateNumberOfRows(sourceCodeWords, errorCorrectionCodeWords, cols);

    if (rows < minRows) {
        break; // No need to check further as rows will only decrease
    }

    if (rows > maxRows) {
        continue; // Skip this column count as it exceeds max rows
    }

    float newRatio = ((float) (17 * cols + 69) * DEFAULT_MODULE_WIDTH) / (rows * HEIGHT);

    // Update if the new ratio is closer to the preferred ratio
    if (dimension == null || Math.abs(newRatio - PREFERRED_RATIO) < Math.abs(ratio - PREFERRED_RATIO)) {
        ratio = newRatio;
        dimension = new int[]{cols, rows};
    }
}

// Handle case when no suitable dimensions were found in the loop
if (dimension == null) {
    int rows = calculateNumberOfRows(sourceCodeWords, errorCorrectionCodeWords, currentCols);
    if (rows >= minRows && rows <= maxRows) {
        dimension = new int[]{currentCols, rows};
    } else {
        throw new WriterException("Unable to fit message in columns");
    }
}

return dimension;

}
generatePDF417Image("0000000001000000022200000003330444400888888881010101010", 371, null);

from zxing.

Related Issues (20)

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.