1 public String GetCheckString(Bitmap bitmap) { 2 UnCodebase ud = new UnCodebase(bitmap); 3 ud.GrayByPixels(); 4 ud.ClearPicBorder(2); 5 ud.CutMap(14, 15, 0, 0); 6 bitmap = ud.bmpobj; 7 // bitmap = ud.ClearNoise(128, 1); 8 String chkcode = ""; 9 Bitmap[] arrmap = ud.SplitImg(bitmap, 4, 1); 10 foreach (Bitmap item in arrmap) { 11 String str = ud.GetCodebybitmap(item, 128); 12 Boolean isEques = false; 13 foreach (String strss in code) { 14 String[] a = strss.Split(':'); 15 if (str == a[1]) { 16 chkcode += a[0]; 17 isEques = true; 18 break; 19 } 20 } 21 if (!isEques) { 22 String strCurrent = ""; 23 double max = 0.0; 24 foreach (String strss in code) { 25 int len1, len2, min, count = 0; 26 String[] a = strss.Split(':'); 27 len1 = a[1].Length; 28 len2 = str.Length; 29 min = len1; 30 if (min > len2) { 31 min = len2; 32 } 33 for (int i = 0; i < min; i++) { 34 if (str[i] == a[1][i]) { 35 count++; 36 } 37 } 38 double currrent = (count * 100.0 / min); 39 if (max < currrent) { 40 max = currrent; 41 strCurrent = a[0].Trim(); 42 } 43 } 44 chkcode += strCurrent.Trim(); 45 } 46 } 47 return chkcode; 48 }