ZXing.PDF417.Internal.PDF417.calculateNumberOfRows(int, int, int)

Here are the examples of the csharp api class ZXing.PDF417.Internal.PDF417.calculateNumberOfRows(int, int, int) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2 Examples 7

1. Example

Project: ZXing.Net
Source File: PDF417.cs
View license
private int[] determineDimensions(int sourceCodeWords, int errorCorrectionCodeWords)
      {
         float ratio = 0.0f;
         int[] dimension = null;

         for (int cols = minCols; cols <= maxCols; cols++)
         {

            int rows = calculateNumberOfRows(sourceCodeWords, errorCorrectionCodeWords, cols);

            if (rows < minRows)
            {
               break;
            }

            if (rows > maxRows)
            {
               continue;
            }

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

            // ignore if previous ratio is closer to preferred ratio
            if (dimension != null && Math.Abs(newRatio - PREFERRED_RATIO) > Math.Abs(ratio - PREFERRED_RATIO))
            {
               continue;
            }

            ratio = newRatio;
            dimension = new int[] {cols, rows};
         }

         // Handle case when min values were larger than necessary
         if (dimension == null)
         {
            int rows = calculateNumberOfRows(sourceCodeWords, errorCorrectionCodeWords, minCols);
            if (rows < minRows)
            {
               dimension = new int[] {minCols, minRows};
            }
         }

         if (dimension == null)
         {
            throw new WriterException("Unable to fit message in columns");
         }

         return dimension;
      }

2. Example

Project: zxing-core
Source File: PDF417.cs
View license
private int[] determineDimensions(int sourceCodeWords, int errorCorrectionCodeWords)
      {
         float ratio = 0.0f;
         int[] dimension = null;

         for (int cols = minCols; cols <= maxCols; cols++)
         {

            int rows = calculateNumberOfRows(sourceCodeWords, errorCorrectionCodeWords, cols);

            if (rows < minRows)
            {
               break;
            }

            if (rows > maxRows)
            {
               continue;
            }

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

            // ignore if previous ratio is closer to preferred ratio
            if (dimension != null && Math.Abs(newRatio - PREFERRED_RATIO) > Math.Abs(ratio - PREFERRED_RATIO))
            {
               continue;
            }

            ratio = newRatio;
            dimension = new int[] {cols, rows};
         }

         // Handle case when min values were larger than necessary
         if (dimension == null)
         {
            int rows = calculateNumberOfRows(sourceCodeWords, errorCorrectionCodeWords, minCols);
            if (rows < minRows)
            {
               dimension = new int[] {minCols, minRows};
            }
         }

         if (dimension == null)
         {
            throw new WriterException("Unable to fit message in columns");
         }

         return dimension;
      }