- Timestamp:
- Jan 5, 2005, 6:02:53 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pwntcha/trunk/src/scode.c
r409 r423 23 23 { 24 24 char *result; 25 int stats[ 256];25 int stats[3 * 256]; 26 26 int x, y, i, incell = 0, cur = 0, xmin = 0; 27 27 int r, g, b; … … 30 30 /* allocate enough place */ 31 31 result = malloc(1024 * sizeof(char)); 32 33 tmp1 = filter_dup(img); 34 35 /* Remove border */ 36 getpixel(img, 1, 1, &r, &g, &b); 37 for(y = 0; y < img->height; y++) 38 { 39 setpixel(tmp1, 0, y, r, g, b); 40 setpixel(tmp1, img->width - 1, y, r, g, b); 41 } 42 43 for(x = 0; x < img->width; x++) 44 { 45 setpixel(tmp1, x, 0, r, g, b); 46 setpixel(tmp1, x, img->height - 1, r, g, b); 47 } 32 48 33 49 /* Detect background: first and last 3 lines */ … … 38 54 for(x = 0; x < img->width; x++) 39 55 { 40 getpixel( img, x, y, &r, &g, &b);41 stats[r ]++;42 getpixel( img, x, img->width- 1 - y, &r, &g, &b);43 stats[r ]++;56 getpixel(tmp1, x, y, &r, &g, &b); 57 stats[r + g + b]++; 58 getpixel(tmp1, x, img->height - 1 - y, &r, &g, &b); 59 stats[r + g + b]++; 44 60 } 45 61 46 62 /* Set non-background colours to 0 */ 47 tmp1 = image_new(img->width, img->height);48 49 63 for(y = 0; y < img->height; y++) 50 64 for(x = 0; x < img->width; x++) 51 65 { 52 getpixel( img, x, y, &r, &g, &b);53 if(stats[r ])66 getpixel(tmp1, x, y, &r, &g, &b); 67 if(stats[r + g + b]) 54 68 setpixel(tmp1, x, y, 255, 255, 255); 55 69 else
Note: See TracChangeset
for help on using the changeset viewer.