From 06c4d1dc6d97167ad5fa5317d1279d27e6b9404f Mon Sep 17 00:00:00 2001 From: sam Date: Mon, 9 May 2005 17:58:06 +0000 Subject: [PATCH] * support for free.fr pop_hotline pic. git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/pwntcha/trunk@478 92316355-f0b4-4df1-b90c-862c8a59935f --- src/scode.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/scode.c b/src/scode.c index c1506b7..b2f459a 100644 --- a/src/scode.c +++ b/src/scode.c @@ -24,7 +24,7 @@ char *decode_scode(struct image *img) char *result; int stats[3 * 256]; int x, y, i, incell = 0, cur = 0, xmin = 0; - int r, g, b; + int r, g, b, r2, g2, b2; struct image *tmp1; /* allocate enough place */ @@ -33,23 +33,31 @@ char *decode_scode(struct image *img) tmp1 = image_dup(img); /* Remove border */ + getpixel(img, 0, 0, &r2, &g2, &b2); getpixel(img, 1, 1, &r, &g, &b); - for(y = 0; y < img->height; y++) - { - setpixel(tmp1, 0, y, r, g, b); - setpixel(tmp1, img->width - 1, y, r, g, b); - } - for(x = 0; x < img->width; x++) + if(r != r2 || g != g2 || b != b2) { - setpixel(tmp1, x, 0, r, g, b); - setpixel(tmp1, x, img->height - 1, r, g, b); + for(y = 0; y < img->height; y++) + { + setpixel(tmp1, 0, y, r, g, b); + setpixel(tmp1, img->width - 1, y, r, g, b); + } + + for(x = 0; x < img->width; x++) + { + setpixel(tmp1, x, 0, r, g, b); + setpixel(tmp1, x, img->height - 1, r, g, b); + } } /* Detect background: first and last 3 lines */ for(i = 0; i < 3 * 256; i++) stats[i] = 0; + /* Set (0, 0) colour to background */ + stats[r2 + g2 + b2] = 1; + for(y = 0; y < 6; y++) { int y2 = (y & 1) ? img->width - 1 - y / 2 : y / 2;