diff options
author | Ondřej Surý <ondrej@sury.org> | 2013-05-20 21:00:15 +0200 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2013-05-20 21:10:28 +0200 |
commit | 66c89e753989956b45289974ee7f1cece1da0c9b (patch) | |
tree | b97baa96f546b0ddd03e83920a9f8ebc631b0568 /src/gd_tiff.c | |
parent | f0ddf2eccd3a7e86541f264f7c228940837bb439 (diff) | |
download | libgd-66c89e753989956b45289974ee7f1cece1da0c9b.tar.gz |
Rewrite readTiffBw to use less variables (Thanks Niels Thykier for catching that)
Diffstat (limited to 'src/gd_tiff.c')
-rw-r--r-- | src/gd_tiff.c | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/src/gd_tiff.c b/src/gd_tiff.c index d289fe1..ec6dd11 100644 --- a/src/gd_tiff.c +++ b/src/gd_tiff.c @@ -500,34 +500,23 @@ static void readTiffBw (const unsigned char *src, int align) { int x = startx, y = starty; - int src_x, src_y; - int k; (void)has_alpha; (void)extra; (void)align; - for (src_y = 0; src_y < height; ++src_y) { - k = 0; - while (k < width) { + for (y = starty; y < starty + height; y++) { + for (x = startx; x < startx + width; x++) { register unsigned char curr = *src++; register unsigned char mask; if (photometric == PHOTOMETRIC_MINISWHITE) { curr = ~curr; } - for (mask = 0x80; mask != 0 && k < width; mask >>= 1) { - if((curr & mask) != 0) { - gdImageSetPixel(im, x, y, 0); - } else { - gdImageSetPixel(im, x, y, 1); - } - ++x; - ++k; + for (mask = 0x80; mask != 0 && x < startx + width; mask >>= 1) { + gdImageSetPixel(im, x, y, ((curr & mask) != 0)?0:1); } - ++src_x; } - y++; } } |