浏览代码

* Workaround for problems with Gandi captchas.

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/pwntcha/trunk@465 92316355-f0b4-4df1-b90c-862c8a59935f
master
sam 20 年前
父节点
当前提交
4fd3fd62e8
共有 1 个文件被更改,包括 20 次插入6 次删除
  1. +20
    -6
      src/scode.c

+ 20
- 6
src/scode.c 查看文件

@@ -50,21 +50,35 @@ char *decode_scode(struct image *img)
for(i = 0; i < 3 * 256; i++)
stats[i] = 0;

for(y = 0; y < 3; y++)
for(y = 0; y < 6; y++)
{
int y2 = (y & 1) ? img->width - 1 - y / 2 : y / 2;
for(x = 0; x < img->width; x++)
{
getpixel(tmp1, x, y, &r, &g, &b);
stats[r + g + b]++;
getpixel(tmp1, x, img->height - 1 - y, &r, &g, &b);
stats[r + g + b]++;
getpixel(tmp1, x, y2, &r, &g, &b);
if(stats[r + g + b] == 0)
{
/* Parse middle line to see if this colour can be removed */
int available = 0, x2, r2, g2, b2;
stats[r + g + b] = 1;
for(x2 = 0; x2 < img->width; x2++)
{
getpixel(tmp1, x2, img->width / 2, &r2, &g2, &b2);
if(stats[r2 + g2 + b2] == 0)
available = 1;
}
if(!available)
stats[r + g + b] = 2;
}
}
}

/* Set non-background colours to 0 */
for(y = 0; y < img->height; y++)
for(x = 0; x < img->width; x++)
{
getpixel(tmp1, x, y, &r, &g, &b);
if(stats[r + g + b])
if(stats[r + g + b] == 1)
setpixel(tmp1, x, y, 255, 255, 255);
else
setpixel(tmp1, x, y, 0, 0, 0);


正在加载...
取消
保存