pike.git / src / modules / Image / togif.c

version» Context lines:

pike.git/src/modules/Image/togif.c:1:   /*      togif    - $Id: togif.c,v 1.23 1997/11/07 07:20:48 mirar Exp $ + $Id: togif.c,v 1.24 1997/11/07 16:37:51 mirar Exp $      old GIF API compat stuff      */      /*   **! module Image   **! note - **! $Id: togif.c,v 1.23 1997/11/07 07:20:48 mirar Exp $ + **! $Id: togif.c,v 1.24 1997/11/07 16:37:51 mirar Exp $   **! class image   */      #include "global.h"      #include <math.h>   #include <ctype.h>      #include "stralloc.h"   #include "global.h"
pike.git/src/modules/Image/togif.c:174:    else if (sp[2+!!ncto-args].type==T_FLOAT)    delay=(unsigned short)(sp[2+!!ncto-args].u.float_number*100);    else    error("Illegal argument %d to image->gif_add()\n",3+!!ncto);    }       if (!ncto)    {    THISOBJ->refs++;    push_object(THISOBJ); -  push_int(256); +  push_int(255);    ncto=clone_object(image_colortable_program,2);    }       if (fs) image_colortable_internal_floyd_steinberg(    get_storage(ncto,image_colortable_program));       pop_n_elems(args);       THISOBJ->refs++;    push_object(THISOBJ);
pike.git/src/modules/Image/togif.c:252:   **! number of colors to quantize to (default is 256)   **! array array(array(int)) colors   **! colors to map to (default is to quantize to 256), format is ({({r,g,b}),({r,g,b}),...}).   **! arg int trans_r   **! arg int trans_g   **! arg int trans_b   **! one color, that is to be transparent.   **! see also: gif_begin, gif_add, gif_end, toppm, fromgif   */    + extern void _image_gif_encode(INT32 args,int fs);      static void img_encode_gif(rgb_group *transparent,int fs,INT32 args)   { -  struct svalue sv; -  -  /* on stack is now: -  - eventual colortable instruction (number or array) */ -  -  /* (swap in) arguments to gif_add, x and y position */ -  push_int(0); if (args) { sv=sp[-1]; sp[-1]=sp[-2]; sp[-2]=sv; } -  push_int(0); if (args) { sv=sp[-1]; sp[-1]=sp[-2]; sp[-2]=sv; } -  -  img_gif_add(args+2,fs,1,transparent); -  image_gif_begin(0); -  -  /* on stack is now: -  - gif image chunk with local palette -  - gif beginning */ -  -  /* swap them... */ -  sv=sp[-1]; sp[-1]=sp[-2]; sp[-2]=sv; -  -  image_gif_end(0); -  -  /* on stack is now: -  - gif beginning -  - image with local palette and eventual gce block -  - gif end chunk */ -  -  f_add(3); +  struct object *co=NULL; +  if (args) +  { +  if (sp[-args].type==T_OBJECT) +  { +  (co=sp[-args].u.object)->refs++; +  pop_n_elems(args);    } -  +  else if (sp[-args].type==T_ARRAY) +  co=clone_object(image_colortable_program,args); +  else if (sp[-args].type==T_INT) +  { +  unsigned long numcolors=sp[-args].u.integer; +  pop_n_elems(args); +  push_object(THISOBJ); THISOBJ->refs++; +  push_int(numcolors); +  co=clone_object(image_colortable_program,2); +  } +  else +  error("Illegal argument to img->togif()\n"); +  } +  else +  { +  push_object(THISOBJ); THISOBJ->refs++; +  push_int(256); +  co=clone_object(image_colortable_program,2); +  } +  push_object(THISOBJ); THISOBJ->refs++; +  push_object(co); +  if (transparent) +  { +  push_int(transparent->r); +  push_int(transparent->g); +  push_int(transparent->b); +  _image_gif_encode(5,fs); +  } +  else _image_gif_encode(2,fs); + }      static INLINE void getrgb(struct image *img,    INT32 args_start,INT32 args,char *name)   {    INT32 i;    if (args-args_start<3) return;    for (i=0; i<3; i++)    if (sp[-args+i+args_start].type!=T_INT)    error("Illegal r,g,b argument to %s\n",name);    img->rgb.r=(unsigned char)sp[-args+args_start].u.integer;