--- parser3/src/classes/gd/Attic/gifio.C 2003/03/18 15:14:15 1.21.2.2.2.1 +++ parser3/src/classes/gd/Attic/gifio.C 2003/03/24 14:53:56 1.21.2.2.2.6 @@ -35,21 +35,25 @@ ** CompuServe Incorporated. */ -static const char* IDENT_GIFIO_C="$Date: 2003/03/18 15:14:15 $"; +static const char* IDENT_GIFIO_C="$Date: 2003/03/24 14:53:56 $"; #include "gif.h" static int colorstobpp(int colors); -void gdImage::GifString& out) +gdBuf gdImage::Gif() { int BitsPerPixel = colorstobpp(colorsTotal); /* Clear any old values in statics strewn through the GIF code */ - gdGifEncoder encoder(pool, *this, out); + CORD_ec x; CORD_ec_init(x); + gdGifEncoder encoder(*this, x); /* All set, let's do it. */ encoder.encode( sx, sy, interlace, 0, transparent, BitsPerPixel, red, green, blue); + + CORD result=CORD_ec_to_cord(x); + return gdBuf(CORD_to_char_star(result), CORD_len(result)); } static int @@ -219,7 +223,8 @@ gdGifEncoder::encode(int GWidth, int GHe /* * 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 @@ -328,9 +333,7 @@ gdGifEncoder::encode(int GWidth, int GHe */ void gdGifEncoder::Putbyte(int c) { - char *p=new char[1]; - *p=c; - fp.APPEND_AS_IS(p, 1, 0, 0); + CORD_ec_append(fp, c); } /* * Write out a word to the GIF file @@ -338,16 +341,16 @@ gdGifEncoder::Putbyte(int c) { void gdGifEncoder::Putword(int w) { - char *p=new char[2]; - p[0]=w & 0xff; - p[1]=(w / 256) & 0xff; - fp.APPEND_AS_IS(p, 2, 0, 0); + CORD_ec_append(fp, w & 0xff); + CORD_ec_append(fp, w >> 8); } +inline void ec_append(CORD_ec& result, char *buf, size_t size) { + while(size--) + CORD_ec_append(result, *buf++); +} void gdGifEncoder::Write(void *buf, size_t size) { - char *p=new char[size]; - memcpy(p, buf, size); - fp.APPEND_AS_IS(p, size, 0, 0); + ec_append(fp, (char*)buf, size); } /*************************************************************************** @@ -681,7 +684,7 @@ void } } -gdGifEncoder::gdGifEncoder(gdImage& aim, String& afp): pool(), +gdGifEncoder::gdGifEncoder(gdImage& aim, CORD_ec& afp): im(aim), fp(afp) { /* Some of these are properly initialized later. What I'm doing