请问下面这个代码的功能是什么?int CGif::GetCode(FILE *fd, int code_size, int flag)
{
static BYTE buf[280];
static int curbit, lastbit, done, last_byte;
int i,j,ret;
BYTE count; if (flag)
{
curbit=0;
lastbit=0;
done=FALSE;
return 0;
} if ((curbit+code_size) >=lastbit)
{
if (done)
{
if (curbit >=lastbit)
{
//m_strGIFError="Ran off the end of my bits";
return 0;
}
return -1;
}
buf[0]=buf[last_byte-2];
buf[1]=buf[last_byte-1]; if ((count=GetDataBlock(fd,&buf[2]))==0)
done=TRUE; last_byte=2+count; curbit=(curbit - lastbit) + 16; lastbit = (2+count)*8;
}
ret=0;
for (i=curbit,j=0; j<code_size;++i,++j)
ret|=((buf[i/8]&(1<<(i% 8)))!=0)<<j; curbit+=code_size; return ret;
}
{
static BYTE buf[280];
static int curbit, lastbit, done, last_byte;
int i,j,ret;
BYTE count; if (flag)
{
curbit=0;
lastbit=0;
done=FALSE;
return 0;
} if ((curbit+code_size) >=lastbit)
{
if (done)
{
if (curbit >=lastbit)
{
//m_strGIFError="Ran off the end of my bits";
return 0;
}
return -1;
}
buf[0]=buf[last_byte-2];
buf[1]=buf[last_byte-1]; if ((count=GetDataBlock(fd,&buf[2]))==0)
done=TRUE; last_byte=2+count; curbit=(curbit - lastbit) + 16; lastbit = (2+count)*8;
}
ret=0;
for (i=curbit,j=0; j<code_size;++i,++j)
ret|=((buf[i/8]&(1<<(i% 8)))!=0)<<j; curbit+=code_size; return ret;
}
解决方案 »
- CString内存泄露的问题
- 哎呀,晕死了都,说话不要说一半好不好,我要的是完整的代码,问个问题着个费劲啊
- <100分> 关于UDP通讯超时重发的"时机"问题!!!(顶着有分!)
- 如何使Web页面与程序交互
- 为什么BCGControlBarPro装完后不能在Visual Studio.net中使用?
- 用什么阅读工具可以打开以PDG为后缀名的电子图书,请热心侠士教我!!!
- 3. 可不可以控制拒绝收发包含某种类型附件的邮件
- 本人遇到个小问题,还很挠头??!如何自画CLISTCTRL的标题头和边上的自动出现的滚动条?
- 我想在ONDRAW()里CREAT()一个类,但不知怎样判别此类是第一次创建!!!!!
- 如何用ADO连接dbf数据库?
- 请教高手一个问题,一定要看看啊,谢谢
- 用MFC编写的应用程序如何读取word文档中的内容显示在richBox控件中,有源代码实例发到邮箱:[email protected]
在看一个对GIF图片文件进行读写的程序中看到的 不晓得什么意思 贴上来问问
{
static int fresh=FALSE;
int code, incode;
static int code_size, set_code_size;
static int max_code, max_code_size;
static int firstcode, oldcode;
static int clear_code, end_code; static unsigned short next[1<<MAX_LZW_BITS];
static BYTE vals[1<<MAX_LZW_BITS];
static BYTE stack [1<<(MAX_LZW_BITS+1)];
static BYTE *sp;
register int i; if (flag)
{
set_code_size=input_code_size;
code_size=set_code_size+1;
clear_code=1<<set_code_size;
end_code = clear_code+1;
max_code = clear_code+2;
max_code_size=2*clear_code; GetCode(fd,0,TRUE); fresh=TRUE;
for(i=0;i<clear_code;++i)
{
next[i]=0;
vals[i]=i;
} for (;i<(1<<MAX_LZW_BITS);++i)
next[i]=vals[0]=0;
sp=stack; return 0;
}
else if (fresh)
{
fresh=FALSE;
do
{
firstcode=oldcode=GetCode(fd,code_size,FALSE);
} while (firstcode==clear_code);
return firstcode;
} if (sp > stack)
return *--sp; while ((code= GetCode(fd,code_size,FALSE)) >=0)
{
if (code==clear_code)
{
for (i=0;i<clear_code;++i)
{
next[i]=0;
vals[i]=i;
}
for (;i<(1<<MAX_LZW_BITS);++i)
next[i]=vals[i]=0;
code_size=set_code_size+1;
max_code_size=2*clear_code;
max_code=clear_code+2;
sp=stack;
firstcode=oldcode=GetCode(fd,code_size,FALSE);
return firstcode;
}
else if (code==end_code)
{
int count;
BYTE buf[260];
if (ZeroDataBlock)
return -2; while ((count=GetDataBlock(fd,buf)) >0); if (count!=0)
//AfxMessageBox("Missing EOD in GIF data stream (common occurrence)",MB_OK);
return -2;
} incode = code; if (code >= max_code)
{
*sp++=firstcode;
code=oldcode;
} while (code >=clear_code)
{
*sp++=vals[code];
if (code==(int)next[code])
{
//m_strGIFError="Circular table entry, big GIF Error!";
return -1;
}
code=next[code];
} *sp++ = firstcode=vals[code]; if ((code=max_code) <(1<<MAX_LZW_BITS))
{
next[code]=oldcode;
vals[code]=firstcode;
++max_code;
if ((max_code >=max_code_size) &&
(max_code_size < (1<<MAX_LZW_BITS)))
{
max_code_size*=2;
++code_size;
}
} oldcode=incode; if (sp > stack)
return *--sp;
}
return code;
}
gif的文件格式中有没有code之类的部分