Skip to content
Snippets Groups Projects
Commit 78a4cfea authored by Mirar (Pontus Hagland)'s avatar Mirar (Pontus Hagland)
Browse files

P4 bug fixed (last byte on row seems to be padded)

P6/maxval=255 optimized

Rev: src/modules/Image/encodings/Makefile.in:1.8
Rev: src/modules/Image/encodings/pnm.c:1.4
parent b0d30c53
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,7 @@ GIF_OBJS = gif.o gif_lzw.o png.o ...@@ -4,7 +4,7 @@ GIF_OBJS = gif.o gif_lzw.o png.o
JPEG_OBJS = jpeg.o JPEG_OBJS = jpeg.o
PNG_OBJS = png.o PNG_OBJS = png.o
PNM_OBJS = pnm.o PNM_OBJS = pnm.o
OBJS=gif.a pnm.a OBJS=gif.a pnm.a png.a
@SET_MAKE@ @SET_MAKE@
......
/* $Id: pnm.c,v 1.3 1997/11/10 14:19:58 mirar Exp $ */ /* $Id: pnm.c,v 1.4 1997/11/20 22:26:58 mirar Exp $ */
/* /*
**! module Image **! module Image
**! note **! note
**! $Id: pnm.c,v 1.3 1997/11/10 14:19:58 mirar Exp $ **! $Id: pnm.c,v 1.4 1997/11/20 22:26:58 mirar Exp $
**! submodule PNM **! submodule PNM
**! **!
**! This submodule keep the PNM encode/decode capabilities **! This submodule keep the PNM encode/decode capabilities
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
#include "stralloc.h" #include "stralloc.h"
#include "global.h" #include "global.h"
RCSID("$Id: pnm.c,v 1.3 1997/11/10 14:19:58 mirar Exp $"); RCSID("$Id: pnm.c,v 1.4 1997/11/20 22:26:58 mirar Exp $");
#include "pike_macros.h" #include "pike_macros.h"
#include "object.h" #include "object.h"
#include "constants.h" #include "constants.h"
...@@ -127,7 +127,7 @@ static INLINE INT32 getnextnum(struct pike_string *s,INT32 *pos) ...@@ -127,7 +127,7 @@ static INLINE INT32 getnextnum(struct pike_string *s,INT32 *pos)
void img_pnm_decode(INT32 args) void img_pnm_decode(INT32 args)
{ {
INT32 type,c=0,maxval=255; INT32 type,c=0,maxval=255;
INT32 pos=0,x,y,i,n; INT32 pos=0,x,y,i,n,nx;
struct object *o; struct object *o;
struct image *new; struct image *new;
rgb_group *d; rgb_group *d;
...@@ -174,6 +174,10 @@ void img_pnm_decode(INT32 args) ...@@ -174,6 +174,10 @@ void img_pnm_decode(INT32 args)
n=x*y; n=x*y;
i=0; i=0;
nx=x;
if (type=='6' && maxval==255) type='+';
while (n--) while (n--)
{ {
switch (type) switch (type)
...@@ -199,6 +203,7 @@ void img_pnm_decode(INT32 args) ...@@ -199,6 +203,7 @@ void img_pnm_decode(INT32 args)
(unsigned char)~(((c>>7)&1)*255); (unsigned char)~(((c>>7)&1)*255);
c<<=1; c<<=1;
i--; i--;
if (!--nx) { i=0; nx=x; } /* pbm; last byte on row is padded */
break; break;
case '5': case '5':
c=getnext(s,&pos); c=getnext(s,&pos);
...@@ -210,6 +215,11 @@ void img_pnm_decode(INT32 args) ...@@ -210,6 +215,11 @@ void img_pnm_decode(INT32 args)
d->g=(unsigned char)((((INT32)getnext(s,&pos))*255L)/maxval); d->g=(unsigned char)((((INT32)getnext(s,&pos))*255L)/maxval);
d->b=(unsigned char)((((INT32)getnext(s,&pos))*255L)/maxval); d->b=(unsigned char)((((INT32)getnext(s,&pos))*255L)/maxval);
break; break;
case '+': /* optimized P6 */
d->r=getnext(s,&pos);
d->g=getnext(s,&pos);
d->b=getnext(s,&pos);
break;
} }
d++; d++;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment