From 3ab3910e87730ba9ecd6d4c9f053424e933ad62f Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Sat, 25 Jul 2009 23:01:44 -0700 Subject: speed increate for P6 netpbm images when maxval is 255 --- src/netpbm.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/netpbm.c b/src/netpbm.c index 0cf4ca6..d87872f 100644 --- a/src/netpbm.c +++ b/src/netpbm.c @@ -120,11 +120,15 @@ int netpbm_read(struct image *img){ img->buf[a++] = val; } }else if(b->format == '6'){ - while(left--){ - img->buf[a++] = readvalb(b); - img->buf[a++] = readvalb(b); - img->buf[a++] = readvalb(b); - } + if(b->maxval == 255){ + fread(img->buf, 1, left * 3, f); + }else{ + while(left--){ + img->buf[a++] = readvalb(b); + img->buf[a++] = readvalb(b); + img->buf[a++] = readvalb(b); + } + } } img->state = LOADED; -- cgit v1.2.3