/[xforms]/xforms/image/image_gif.c
ViewVC logotype

Diff of /xforms/image/image_gif.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by leeming, Fri Nov 21 13:23:23 2003 UTC revision 1.6 by leeming, Thu Nov 27 10:29:47 2003 UTC
# Line 585  GIF_load(FL_IMAGE * im) Line 585  GIF_load(FL_IMAGE * im)
585  #define OUTPIX(c)   *lbuf++ = (c)  #define OUTPIX(c)   *lbuf++ = (c)
586  #define MC_SIZE      4097  #define MC_SIZE      4097
587    
588    /* if we've got more than one scanline, output */
589    static void flush_buffer(FL_IMAGE * im, int incode)
590    {
591        int i;
592    
593        incode = lbuf - lhead;
594        if (incode >= im->w)
595        {
596            lbuf = lhead;
597    
598            while (incode >= im->w)
599            {
600                outputline(im, lbuf);
601                incode -= im->w;
602                lbuf += im->w;
603            }
604    
605            /* copy the left over */
606            for (i = 0; i < incode; i++)
607                lhead[i] = *lbuf++;
608            lbuf = lhead + incode;
609        }
610    }
611    
612    
613  static int  static int
614  process_lzw_code(FL_IMAGE * im, register int code)  process_lzw_code(FL_IMAGE * im, register int code)
615  {  {
616      register int incode, i;      register int incode;
617      static unsigned char firstchar;      static unsigned char firstchar;
618      static unsigned char stack[MC_SIZE];      static unsigned char stack[MC_SIZE];
619      static int avail, oldcode;      static int avail, oldcode;
# Line 637  process_lzw_code(FL_IMAGE * im, register Line 662  process_lzw_code(FL_IMAGE * im, register
662      {      {
663          OUTPIX(suffix[code]);          OUTPIX(suffix[code]);
664          firstchar = oldcode = code;          firstchar = oldcode = code;
665            /* Clive Stubbings.
666             * There is the posibility of an image with just alternate
667             * single code bytes and resets. I know thats really dumb,
668             * but I found one and it took a long time to work out why
669             * it crashed...
670             * So flush the buffer before it overuns.
671             */
672            flush_buffer(im, incode);
673          return 0;          return 0;
674      }      }
675    
# Line 676  process_lzw_code(FL_IMAGE * im, register Line 709  process_lzw_code(FL_IMAGE * im, register
709      while (stackp > stack);      while (stackp > stack);
710    
711      /* if we've got more than one scanline, output */      /* if we've got more than one scanline, output */
712      incode = lbuf - lhead;      flush_buffer(im, incode);
     if (incode >= im->w)  
     {  
         lbuf = lhead;  
   
         while (incode >= im->w)  
         {  
             outputline(im, lbuf);  
             incode -= im->w;  
             lbuf += im->w;  
         }  
   
         /* copy the left over */  
         for (i = 0; i < incode; i++)  
             lhead[i] = *lbuf++;  
         lbuf = lhead + incode;  
     }  
713      return 0;      return 0;
714  }  }
715    

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26