Changeset 448 for pwntcha/trunk/src/authimage.c
- Timestamp:
- 01/10/05 16:31:33 (8 years ago)
- File:
-
- 1 edited
-
pwntcha/trunk/src/authimage.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
pwntcha/trunk/src/authimage.c
r445 r448 19 19 #include "common.h" 20 20 21 #define FONTNAME "font_authimage.png"22 static struct image *font = NULL;23 24 21 /* Main function */ 25 22 char *decode_authimage(struct image *img) 26 23 { 27 char *all = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";24 static struct font *font = NULL; 28 25 char *result; 29 26 struct image *tmp; … … 32 29 if(!font) 33 30 { 34 char fontname[BUFSIZ]; 35 sprintf(fontname, "%s/%s", share, FONTNAME); 36 font = image_load(fontname); 31 font = font_load_fixed("font_authimage.png", 32 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"); 37 33 if(!font) 38 {39 fprintf(stderr, "cannot load font %s\n", fontname);40 34 exit(-1); 41 }42 35 } 43 36 … … 46 39 memset(result, '\0', 7); 47 40 48 /* half the captchas are inverse video; we set them back to normal*/41 /* double the captcha size for better accuracy in the rotation */ 49 42 tmp = image_dup(img); 50 43 filter_scale(tmp, 2.0); … … 52 45 filter_equalize(tmp, r * 3 / 4); 53 46 filter_smooth(tmp); 47 filter_equalize(tmp, 220); 54 48 55 49 for(i = 0; i < 6; i++) 56 50 { 57 51 int mindiff = INT_MAX, minch = -1, ch; 58 for(ch = 0; ch < 36; ch++)52 for(ch = 0; ch < font->size; ch++) 59 53 { 60 54 int diff = 0; … … 67 61 newy = 33.0 - (x + 6 * i) * 18.0 / 34.0 + y * 42.0 / 6.0 + 0.5; 68 62 getpixel(tmp, newx, newy, &r, &g, &b); 69 getpixel(font, x + 6 * ch, y, &r2, &g, &b); 70 r = (r < 220) ? 0 : 255; 63 getpixel(font->img, x + 6 * ch, y, &r2, &g, &b); 71 64 diff += (r - r2) * (r - r2); 72 65 } … … 78 71 } 79 72 } 80 result[i] = all[minch];73 result[i] = font->glyphs[minch].c; 81 74 } 82 75
Note: See TracChangeset
for help on using the changeset viewer.
