All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pdfjet.QRUtil Maven / Gradle / Ivy

/*     */ package com.pdfjet;
/*     */ 
/*     */ class QRUtil
/*     */ {
/*     */   private static final int G15 = 1335;
/*     */   private static final int G15_MASK = 21522;
/*     */ 
/*     */   protected static Polynomial getErrorCorrectPolynomial(int paramInt)
/*     */   {
/*  25 */     Polynomial localPolynomial = new Polynomial(new int[] { 1 });
/*  26 */     for (int i = 0; i < paramInt; i++) {
/*  27 */       localPolynomial = localPolynomial.multiply(new Polynomial(new int[] { 1, QRMath.gexp(i) }));
/*     */     }
/*  29 */     return localPolynomial;
/*     */   }
/*     */ 
/*     */   protected static boolean getMask(int paramInt1, int paramInt2, int paramInt3) {
/*  33 */     switch (paramInt1) {
/*     */     case 0:
/*  35 */       return (paramInt2 + paramInt3) % 2 == 0;
/*     */     case 1:
/*  36 */       return paramInt2 % 2 == 0;
/*     */     case 2:
/*  37 */       return paramInt3 % 3 == 0;
/*     */     case 3:
/*  38 */       return (paramInt2 + paramInt3) % 3 == 0;
/*     */     case 4:
/*  39 */       return (paramInt2 / 2 + paramInt3 / 3) % 2 == 0;
/*     */     case 5:
/*  40 */       return paramInt2 * paramInt3 % 2 + paramInt2 * paramInt3 % 3 == 0;
/*     */     case 6:
/*  41 */       return (paramInt2 * paramInt3 % 2 + paramInt2 * paramInt3 % 3) % 2 == 0;
/*     */     case 7:
/*  42 */       return (paramInt2 * paramInt3 % 3 + (paramInt2 + paramInt3) % 2) % 2 == 0;
/*     */     }
/*     */ 
/*  45 */     throw new IllegalArgumentException("mask: " + paramInt1);
/*     */   }
/*     */ 
/*     */   protected static int getLostPoint(QRCode paramQRCode)
/*     */   {
/*  50 */     int i = paramQRCode.getModuleCount();
/*  51 */     int j = 0;
/*     */     int n;
/*  54 */     for (int k = 0; k < i; k++) {
/*  55 */       for (m = 0; m < i; m++) {
/*  56 */         n = 0;
/*  57 */         boolean bool = paramQRCode.isDark(k, m);
/*     */ 
/*  59 */         for (int i1 = -1; i1 <= 1; i1++) {
/*  60 */           if ((k + i1 >= 0) && (i > k + i1))
/*     */           {
/*  64 */             for (int i2 = -1; i2 <= 1; i2++)
/*  65 */               if ((m + i2 >= 0) && (i > m + i2))
/*     */               {
/*  69 */                 if ((i1 != 0) || (i2 != 0))
/*     */                 {
/*  73 */                   if (bool == paramQRCode.isDark(k + i1, m + i2))
/*  74 */                     n++;
/*     */                 }
/*     */               }
/*     */           }
/*     */         }
/*  79 */         if (n > 5) {
/*  80 */           j += 3 + n - 5;
/*     */         }
/*     */       }
/*     */ 
/*     */     }
/*     */ 
/*  86 */     for (k = 0; k < i - 1; k++) {
/*  87 */       for (m = 0; m < i - 1; m++) {
/*  88 */         n = 0;
/*  89 */         if (paramQRCode.isDark(k, m)) n++;
/*  90 */         if (paramQRCode.isDark(k + 1, m)) n++;
/*  91 */         if (paramQRCode.isDark(k, m + 1)) n++;
/*  92 */         if (paramQRCode.isDark(k + 1, m + 1)) n++;
/*  93 */         if ((n == 0) || (n == 4)) {
/*  94 */           j += 3;
/*     */         }
/*     */       }
/*     */ 
/*     */     }
/*     */ 
/* 100 */     for (k = 0; k < i; k++) {
/* 101 */       for (m = 0; m < i - 6; m++) {
/* 102 */         if ((paramQRCode.isDark(k, m)) && (!paramQRCode.isDark(k, m + 1)) && (paramQRCode.isDark(k, m + 2)) && (paramQRCode.isDark(k, m + 3)) && (paramQRCode.isDark(k, m + 4)) && (!paramQRCode.isDark(k, m + 5)) && (paramQRCode.isDark(k, m + 6)))
/*     */         {
/* 109 */           j += 40;
/*     */         }
/*     */       }
/*     */     }
/*     */ 
/* 114 */     for (k = 0; k < i; k++) {
/* 115 */       for (m = 0; m < i - 6; m++) {
/* 116 */         if ((paramQRCode.isDark(m, k)) && (!paramQRCode.isDark(m + 1, k)) && (paramQRCode.isDark(m + 2, k)) && (paramQRCode.isDark(m + 3, k)) && (paramQRCode.isDark(m + 4, k)) && (!paramQRCode.isDark(m + 5, k)) && (paramQRCode.isDark(m + 6, k)))
/*     */         {
/* 123 */           j += 40;
/*     */         }
/*     */       }
/*     */ 
/*     */     }
/*     */ 
/* 129 */     k = 0;
/* 130 */     for (int m = 0; m < i; m++) {
/* 131 */       for (n = 0; n < i; n++) {
/* 132 */         if (paramQRCode.isDark(n, m)) {
/* 133 */           k++;
/*     */         }
/*     */       }
/*     */     }
/*     */ 
/* 138 */     m = Math.abs(100 * k / i / i - 50) / 5;
/* 139 */     j += m * 10;
/*     */ 
/* 141 */     return j;
/*     */   }
/*     */ 
/*     */   public static int getBCHTypeInfo(int paramInt)
/*     */   {
/* 149 */     int i = paramInt << 10;
/* 150 */     while (getBCHDigit(i) - getBCHDigit(1335) >= 0) {
/* 151 */       i ^= 1335 << getBCHDigit(i) - getBCHDigit(1335);
/*     */     }
/* 153 */     return (paramInt << 10 | i) ^ 0x5412;
/*     */   }
/*     */ 
/*     */   private static int getBCHDigit(int paramInt) {
/* 157 */     int i = 0;
/* 158 */     while (paramInt != 0) {
/* 159 */       i++;
/* 160 */       paramInt >>>= 1;
/*     */     }
/* 162 */     return i;
/*     */   }
/*     */ }

/* Location:           E:\EGGWIFI\Customer\trunk\src\Workspace\Customer\Customer Maven Webapp\src\main\webapp\WEB-INF\lib\PDFjet.jar
 * Qualified Name:     com.pdfjet.QRUtil
 * JD-Core Version:    0.6.2
 */




© 2015 - 2024 Weber Informatics LLC | Privacy Policy