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

version» Context lines:

pike.git/src/modules/Image/togif.c:1:   /*      togif      Pontus Hagland, law@infovav.se    - $Id: togif.c,v 1.5 1997/03/18 17:36:23 mirar Exp $ + $Id: togif.c,v 1.6 1997/04/03 07:00:43 mirar Exp $      */    -  + /* + **! module Image + **! class image + */ +    #include "global.h"      #include <math.h>   #include <ctype.h>      #include "stralloc.h"   #include "global.h"   #include "threads.h"   #include "types.h"   #include "pike_macros.h"
pike.git/src/modules/Image/togif.c:440:    }    while (0);    THREADS_DISALLOW();       if (arena) free(arena);    return 1; /* ok */   }          + /* + **! method object fromgif(string gif) + **! Reads GIF data to the called image object. + **! + **! GIF animation delay or loops are ignored, + **! and the resulting image is the written result. + **! returns the called object + **! arg string pnm + **! pnm data, as a string + **! see also: togif, frompnm + **! known bugs: yes, it does -- it may even do segment overrides... + */ +    void image_fromgif(INT32 args)   {    if (sp[-args].type!=T_STRING)    error("Illegal argument to image->fromgif()\n");       if (THIS->img) free(THIS->img);    THIS->img=NULL;       image_decode_gif(THIS,NULL,sp[-args].u.string->str,sp[-args].u.string->len);   
pike.git/src/modules/Image/togif.c:475:    img->rgb.b=(unsigned char)sp[2-args+args_start].u.integer;    if (args-args_start>=4)    if (sp[3-args+args_start].type!=T_INT)    error("Illegal alpha argument to %s\n",name);    else    img->alpha=sp[3-args+args_start].u.integer;    else    img->alpha=0;   }    + /* + **! method string togif() + **! method string togif(int num_colors) + **! method string togif(array(array(int)) colors) + **! method string togif(int trans_r,int trans_g,int trans_b) + **! method string togif(int num_colors,int trans_r,int trans_g,int trans_b) + **! method string togif(array(array(int)) colors,int trans_r,int trans_g,int trans_b) + **! method string togif_fs() + **! method string togif_fs(int num_colors) + **! method string togif_fs(array(array(int)) colors) + **! method string togif_fs(int trans_r,int trans_g,int trans_b) + **! method string togif_fs(int num_colors,int trans_r,int trans_g,int trans_b) + **! method string togif_fs(array(array(int)) colors,int trans_r,int trans_g,int trans_b) + **! Makes GIF data. The togif_fs variant uses floyd-steinberg + **! dithereing. + **! returns the GIF data + **! + **! arg int num_colors + **! 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: togif_begin, togif_add, togif_end, toppm, fromgif + */ +    void image_togif(INT32 args)   {    rgb_group *transparent=NULL;    struct colortable *ct=NULL;       if (args>0 && sp[-args].type==T_ARRAY)    ct=colortable_from_array(sp[-args].u.array,"image->togif()\n");    else if (args>0 && args!=3 && sp[-args].type==T_INT)    ct=colortable_quant(THIS,min(256,max(2,sp[-args].u.integer)));   
pike.git/src/modules/Image/togif.c:529:       pop_n_elems(args);    if (!THIS->img) { error("no image\n"); return; }       if (!ct)    ct=colortable_quant(THIS,256);    push_string( image_encode_gif( THIS,ct, transparent, 1, closest) );    colortable_free(ct);   }    + /* + **! method string gif_begin() + **! method string gif_begin(int num_colors) + **! method string gif_begin(array(array(int)) colors) + **! Makes GIF header. With no argument, there is no + **! global colortable (palette). + **! returns the GIF data + **! + **! arg int num_colors + **! number of colors to quantize to (default is 256) + **! array array(array(int)) colors + **! colors to map to, format is ({({r,g,b}),({r,g,b}),...}). + **! see also: gif_add, gif_end, togif, gif_netscape_loop + **! + **! + **! method string gif_end() + **! Ends GIF data. + **! returns the GIF data. + **! see also: gif_begin + */ +    void image_gif_begin(INT32 args)   {    dynamic_buffer buf;    long i;    int colors,bpp;    struct colortable *ct=NULL;       if (args)    if (sp[-args].type==T_INT && sp[-args].u.integer!=0)    ct=colortable_quant(THIS,max(256,min(2,sp[-args].u.integer)));
pike.git/src/modules/Image/togif.c:592:    }    push_string(low_free_buf(&buf));   }      void image_gif_end(INT32 args)   {    pop_n_elems(args);    push_string(make_shared_binary_string(";",1));   }    + /* + **! method string gif_netscape_loop() + **! method string gif_netscape_loop(int loops) + **! + **! returns a gif chunk that defines that the GIF animation should loop + **! + **! arg int loops + **! number of loops, default is 65535. + **! see also: gif_add, gif_begin, gif_end + */ +    void image_gif_netscape_loop(INT32 args)   {    unsigned short loops=0;    char buf[30];    if (args)    if (sp[-args].type!=T_INT)    error("Illegal argument to image->gif_netscape_loop()\n");    else    loops=sp[-args].u.integer;    else
pike.git/src/modules/Image/togif.c:627:    dynamic_buffer buf;    int colors,bpp;    int closest=0;      CHRONO("gif add init");       buf.s.str=NULL;    initialize_buf(&buf);       if (args==0) x=y=0; -  else if (sp[-args].type!=T_INT +  else if (args<2 +  || sp[-args].type!=T_INT    || sp[1-args].type!=T_INT)    error("Illegal argument(s) to image->gif_add()\n");    else    {    x=sp[-args].u.integer;    y=sp[1-args].u.integer;    }          if (args>2 && sp[2-args].type==T_ARRAY)
pike.git/src/modules/Image/togif.c:762:       colortable_free(ct);    THREADS_DISALLOW();      CHRONO("done");       pop_n_elems(args);    push_string(low_free_buf(&buf));   }    + /* + **! method string gif_add() + **! method string gif_add(int x,int y) + **! method string gif_add(int x,int y,int delay_cs) + **! method string gif_add(int x,int y,float delay_s) + **! method string gif_add(int x,int y,int num_colors,int delay_cs) + **! method string gif_add(int x,int y,int num_colors,float delay_s) + **! method string gif_add(int x,int y,array(array(int)) colors,int delay_cs) + **! method string gif_add(int x,int y,array(array(int)) colors,float delay_s) + **! method string gif_add_fs() + **! method string gif_add_fs(int x,int y) + **! method string gif_add_fs(int x,int y,int delay_cs) + **! method string gif_add_fs(int x,int y,float delay_s) + **! method string gif_add_fs(int x,int y,int num_colors,int delay_cs) + **! method string gif_add_fs(int x,int y,int num_colors,float delay_s) + **! method string gif_add_fs(int x,int y,array(array(int)) colors,int delay_cs) + **! method string gif_add_fs(int x,int y,array(array(int)) colors,float delay_s) + **! method string gif_add_nomap() + **! method string gif_add_nomap(int x,int y) + **! method string gif_add_nomap(int x,int y,int delay_cs) + **! method string gif_add_nomap(int x,int y,float delay_s) + **! method string gif_add_nomap(int x,int y,int num_colors,int delay_cs) + **! method string gif_add_nomap(int x,int y,int num_colors,float delay_s) + **! method string gif_add_nomap(int x,int y,array(array(int)) colors,int delay_cs) + **! method string gif_add_nomap(int x,int y,array(array(int)) colors,float delay_s) + **! method string gif_add_fs_nomap() + **! method string gif_add_fs_nomap(int x,int y) + **! method string gif_add_fs_nomap(int x,int y,int delay_cs) + **! method string gif_add_fs_nomap(int x,int y,float delay_s) + **! method string gif_add_fs_nomap(int x,int y,int num_colors,int delay_cs) + **! method string gif_add_fs_nomap(int x,int y,int num_colors,float delay_s) + **! method string gif_add_fs_nomap(int x,int y,array(array(int)) colors,int delay_cs) + **! method string gif_add_fs_nomap(int x,int y,array(array(int)) colors,float delay_s) + **! Makes a GIF (sub)image data chunk, to be placed + **! at the given position. The "fs" versions uses + **! floyd-steinberg dithering, and the "nomap" versions + **! have no local colormap. + **! returns the GIF data + **! + **! arg int x + **! arg int y + **! the location of this subimage + **! arg int delay_cs + **! frame delay in centiseconds + **! arg float delay_s + **! frame delay in seconds + **! arg int num_colors + **! number of colors to quantize to (default is 256) + **! arg array array(array(int)) colors + **! colors to map to, format is ({({r,g,b}),({r,g,b}),...}). + **! see also: gif_add, gif_end, gif_netscape_loop, togif + */ +    void image_gif_add(INT32 args)   {    img_gif_add(args,0,1);   }      void image_gif_add_fs(INT32 args)   {    img_gif_add(args,1,1);   }      void image_gif_add_nomap(INT32 args)   {    img_gif_add(args,0,0);   }      void image_gif_add_fs_nomap(INT32 args)   {    img_gif_add(args,1,0);   }