Diff for /parser3/src/classes/gd/Attic/gifio.C between versions 1.15 and 1.23

version 1.15, 2001/11/05 11:46:22 version 1.23, 2003/11/20 16:34:24
Line 1 Line 1
 /** @file  /** @file
         Parser: image manipulations impl2.          Parser: image manipulations impl2.
   
         Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)          Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com)
         Author: Alexander Petrosyan <paf@design.ru> (http://paf.design.ru)          Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
   
         $Id$  
   
         based on: gd          based on: gd
   
Line 37 Line 35
  ** CompuServe Incorporated.   ** CompuServe Incorporated.
 */  */
   
   static const char * const IDENT_GIFIO_C="$Date$";
   
 #include "gif.h"  #include "gif.h"
   
 static int colorstobpp(int colors);  static int colorstobpp(int colors);
   
 void gdImage::Gif(String& out)  gdBuf gdImage::Gif()
 {  {
         int BitsPerPixel = colorstobpp(colorsTotal);          int BitsPerPixel = colorstobpp(colorsTotal);
         /* Clear any old values in statics strewn through the GIF code */          /* Clear any old values in statics strewn through the GIF code */
         gdGifEncoder encoder(pool(), *this, out);          gdGifEncoder encoder(*this);
         /* All set, let's do it. */          /* All set, let's do it. */
         encoder.encode(          return encoder.encode(
                 sx, sy, interlace, 0, transparent, BitsPerPixel,                  sx, sy, interlace, 0, transparent, BitsPerPixel,
                 red, green, blue);                  red, green, blue);
 }  }
Line 85  colorstobpp(int colors) Line 85  colorstobpp(int colors)
 *  *
 *****************************************************************************/  *****************************************************************************/
   
   #ifndef TRUE
 #define TRUE 1  #define TRUE 1
   #endif
   #ifndef FALSE
 #define FALSE 0  #define FALSE 0
   #endif
   
 /*  /*
 * Bump the 'curx' and 'cury' to point to the next pixel  * Bump the 'curx' and 'cury' to point to the next pixel
Line 166  gdGifEncoder::GIFNextPixel() Line 170  gdGifEncoder::GIFNextPixel()
   
 /* public */  /* public */
   
 void  gdBuf
 gdGifEncoder::encode(int GWidth, int GHeight,   gdGifEncoder::encode(int GWidth, int GHeight, 
                                          int GInterlace, int Background, int Transparent, int BitsPerPixel,                                            int GInterlace, int Background, int Transparent, int BitsPerPixel, 
                                          int *Red, int *Green, int *Blue)                                           int *Red, int *Green, int *Blue)
Line 215  gdGifEncoder::encode(int GWidth, int GHe Line 219  gdGifEncoder::encode(int GWidth, int GHe
         /*          /*
         * Write the Magic header          * Write the Magic header
         */          */
         fp << (Transparent < 0 ? "GIF87a" : "GIF89a");          Putbyte('G');Putbyte('I');Putbyte('F');
           Putbyte('8');Putbyte(Transparent < 0?'7':'9');Putbyte('a');
                   
         /*          /*
         * Write out the screen width and height          * Write out the screen width and height
Line 317  gdGifEncoder::encode(int GWidth, int GHe Line 322  gdGifEncoder::encode(int GWidth, int GHe
         * Write the GIF file terminator          * Write the GIF file terminator
         */          */
         Putbyte( ';');          Putbyte( ';');
   
           return buf;
 }  }
   
 /*  /*
 * Write out a byte to the GIF file  * Write out a byte to the GIF file
 */  */
 void   void 
 gdGifEncoder::Putbyte(int c) {  gdGifEncoder::Putbyte(unsigned char c) {
         char *p=(char *)malloc(1);          buf.append(&c, 1);
         *p=c;  
         fp.APPEND_AS_IS(p, 1, 0, 0);  
 }  }
 /*  /*
 * Write out a word to the GIF file  * Write out a word to the GIF file
Line 334  gdGifEncoder::Putbyte(int c) { Line 339  gdGifEncoder::Putbyte(int c) {
 void  void
 gdGifEncoder::Putword(int w)  gdGifEncoder::Putword(int w)
 {  {
         char *p=(char *)malloc(2);          unsigned char b0=w & 0xff;
         p[0]=w & 0xff;          unsigned char b1=w >> 8;
         p[1]=(w / 256) & 0xff;          buf.append(&b0, 1);
         fp.APPEND_AS_IS(p, 2, 0, 0);          buf.append(&b1, 1);
 }  }
   
 void gdGifEncoder::Write(void *buf, size_t size) {  void gdGifEncoder::Write(void *abuf, size_t size) {
         char *p=(char *)malloc(size);          buf.append((unsigned char*)abuf, size);
         memcpy(p, buf, size);  
         fp.APPEND_AS_IS(p, size, 0, 0);  
 }  }
   
 /***************************************************************************  /***************************************************************************
Line 677  void Line 680  void
         }          }
 }  }
   
 gdGifEncoder::gdGifEncoder(Pool& pool, gdImage& aim, String& afp) : Pooled(pool),  gdGifEncoder::gdGifEncoder(gdImage& aim): 
         im(aim),           im(aim) {
         fp(afp) {  
         /* Some of these are properly initialized later. What I'm doing          /* Some of these are properly initialized later. What I'm doing
         here is making sure code that depends on C's initialization          here is making sure code that depends on C's initialization
         of statics doesn't break when the code gets called more          of statics doesn't break when the code gets called more
Line 723  gdGifEncoder::gdGifEncoder(Pool& pool, g Line 725  gdGifEncoder::gdGifEncoder(Pool& pool, g
   
 #define        MAXCOLORMAPSIZE         256  #define        MAXCOLORMAPSIZE         256
                   
   #ifndef TRUE
 #define        TRUE    1  #define        TRUE    1
   #endif
   #ifndef FALSE
 #define        FALSE   0  #define        FALSE   0
   #endif
                   
 #define CM_RED         0  #define CM_RED         0
 #define CM_GREEN       1  #define CM_GREEN       1

Removed from v.1.15  
changed lines
  Added in v.1.23


E-mail: