有人有下面这段代码的完全版吗?
是LZW算法在GIF中的使用,急着要用,没有时间自己写
void PackGif(FILE *fp,char far *ImageData,
unsigned int width,unsigned int depth,int BitsPerPixel)
{kk1}
register int i,j;
unsigned char ThisChar;
int code;
char far *bitmap = ImageData;
index = 1;
pixmask = 0xff;
remcnt = 0;
rem = 0;
InitCnt = 0;
First_Char = BitsPerPixel;
CLEAR = 1 << BitsPerPixel; . //256,16,or 4
EOI = CLEAR + 1;
oldcode = -1;
memset( CTfirst,0,4096 );
memset( CTlink,0,8192 );
memset( CTnext,0,8192 );
PackInit( CLEAR );
PutCode( fp,CLEAR );
for( i=0;i<depth;i++ )
{kk1}
for( j=0;j<width;j++ )
{kk1}
ThisChar = bitmap[j];
code = LookupCT(oldcode,ThisChar);
if( code != -1)
oldcode = code;
else{kk1}
PutCode( fp,oldcode );
oldcode = (int) ThisChar;
}
if (nextcode>nextlim)
{kk1} if (reqcnt==12)
{kk1}
PutCode( fp,oldcode );
PutCode( fp,CLEAR ); /* Position */
PackInit(CLEAR); }
else {kk1} reqcnt ++;
nextlim = nextlim << 1;
if (reqcnt==12) nextlim--;
} } }
bitmap = farptr( bitmap,(long)width ); }
PutCode( fp,oldcode );
PutCode( fp,EOI );
Flush( fp );
fputc( 0,fp );
fputc( 0x3b,fp );
return ;
}