📄 gifdeclib.c
字号:
if(NU_SUCCESS !=NU_Allocate_Memory(&System_Memory,&stmp,stackSize*sizeof(U8),0)){
NU_Deallocate_Memory(stack);
NU_Deallocate_Memory(suffix);
NU_Deallocate_Memory(prefix);
return FALSE;
}
memcpy(stmp,stack,stackSize-deltaSize);
NU_Deallocate_Memory(stack);
stack = stmp;
sp = stack + stackSize - deltaSize;
}
}
while (MyCode >= newcodes)
{
*sp++ = suffix[MyCode];
if(sp==stack+stackSize){
stackSize += deltaSize;
if(NU_SUCCESS !=NU_Allocate_Memory(&System_Memory,&stmp,stackSize*sizeof(U8),0)){
NU_Deallocate_Memory(stack);
NU_Deallocate_Memory(suffix);
NU_Deallocate_Memory(prefix);
return FALSE;
}
memcpy(stmp,stack,stackSize-deltaSize);
NU_Deallocate_Memory(stack);
stack = stmp;
sp = stack + stackSize - deltaSize;
}
if(MyCode >=prefixSize){
prefixSize += deltaSize;
if(NU_SUCCESS !=NU_Allocate_Memory(&System_Memory,&ptmp,prefixSize*sizeof(U16),0)){
NU_Deallocate_Memory(stack);
NU_Deallocate_Memory(suffix);
NU_Deallocate_Memory(prefix);
return FALSE;
}
memcpy(stmp,prefix,(prefixSize-deltaSize)*2);
NU_Deallocate_Memory(prefix);
prefix = stmp;
}
MyCode = prefix[MyCode];
}
*sp++ = MyCode;
if(sp==stack+stackSize){
stackSize += deltaSize;
if(NU_SUCCESS !=NU_Allocate_Memory(&System_Memory,&stmp,stackSize*sizeof(U8),0)){
NU_Deallocate_Memory(stack);
NU_Deallocate_Memory(suffix);
NU_Deallocate_Memory(prefix);
return FALSE;
}
memcpy(stmp,stack,stackSize-deltaSize);
NU_Deallocate_Memory(stack);
stack = stmp;
sp = stack+stackSize-deltaSize;
}
if (slot < TopSlot)
{
if(slot>=suffixSize){
suffixSize += deltaSize;
if(NU_SUCCESS !=NU_Allocate_Memory(&System_Memory,&stmp,suffixSize*sizeof(U8),0)){
NU_Deallocate_Memory(stack);
NU_Deallocate_Memory(suffix);
NU_Deallocate_Memory(prefix);
return FALSE;
}
memcpy(stmp,suffix,suffixSize-deltaSize);
NU_Deallocate_Memory(suffix);
suffix = stmp;
}
suffix[slot] = FCode = MyCode;
prefix[slot++] = OldCode ;
if(slot >=prefixSize){
prefixSize += deltaSize;
if(NU_SUCCESS !=NU_Allocate_Memory(&System_Memory,&stmp,prefixSize*sizeof(U16),0)){
NU_Deallocate_Memory(stack);
NU_Deallocate_Memory(suffix);
NU_Deallocate_Memory(prefix);
return FALSE;
}
memcpy(stmp,prefix,(prefixSize-deltaSize)*2);
NU_Deallocate_Memory(prefix);
prefix = stmp;
}
OldCode = NewCode;
}
if (slot >= TopSlot)
if (cCurCodeSize < 12)
{
TopSlot <<= 1;
++cCurCodeSize;
}
while (sp > stack)
{
Output = *(--sp);
GetRGB(pImage,pFrame,NULL,Output,&R,&G,&B);
if(pFrame->m_ImaDesExt_sPackFields.m_InterlaceFlag){
if(!InterLaceWriteToFrame(pFrame,WritePos++,R,G,B)){
NU_Deallocate_Memory(stack);
NU_Deallocate_Memory(suffix);
NU_Deallocate_Memory(prefix);
return FALSE;
}
}
else{
if(!WriteToFrame(pFrame,WritePos++,R,G,B)){
NU_Deallocate_Memory(stack);
NU_Deallocate_Memory(suffix);
NU_Deallocate_Memory(prefix);
return FALSE;
}
}
}
}
}
break;
}
cCurByte = pSData[step++] ;
}
NU_Deallocate_Memory(stack);
NU_Deallocate_Memory(suffix);
NU_Deallocate_Memory(prefix);
return TRUE;
}
U16 GetNewCode(TFrame *pFrame,
U8 *pSData,
U8 cCurCodeSize,
U8 *pcCurByte,
int *step,
U16 *pBitPos,
U16 *pByteCountInBlock)
{
U16 i , Result ;
Result = 0 ;
for (i = 0 ; i <= cCurCodeSize-1; i ++)
{
Result = Result >> 1 ;
if (((*pcCurByte) & 0x01) == 0x01 )
Result = Result |(1 << (cCurCodeSize-1));
else
Result = Result & ( ~( 1 << ( cCurCodeSize-1))) ;
(*pcCurByte)= (*pcCurByte) >> 1 ;
(*pBitPos) ++ ;
if ( (*pBitPos) == 8 )
{
(*pBitPos) = 0 ;
(*pcCurByte) = pSData[(*step)++] ;
if ( *pByteCountInBlock != ( pFrame->m_nBlockSize-1))
(*pByteCountInBlock)++;
else
{
pFrame->m_nBlockSize = pSData[(*step)++];
*pByteCountInBlock = 0 ;
if (pFrame->m_nBlockSize == 0)
return 0 ;
}
}
}
return( Result ) ;
}
void GetRGB(TImage *pImage,
TFrame *pFrame,
U8 *pSData,
U8 index,
U8 * pR,
U8 *pG,
U8 *pB)
{
U8 *clrTable;
clrTable = &(pImage->m_pRawData[pFrame->m_LCTPos]);
*pR = clrTable[index * 3 + 0];
*pG = clrTable[index * 3 + 1];
*pB = clrTable[index * 3 + 2];
return;
}
BOOL WriteToFrame(TFrame *pFrame,
int WritePos,
U8 R,
U8 G,
U8 B)
{
static int curP;
int nWidth,nHeight;
int i;
nWidth = pFrame->m_imageDescriptor.m_wWidth;
nHeight = pFrame->m_imageDescriptor.m_wHeight;
if(WritePos == 0)
{
curP = 0;
if(NU_SUCCESS != NU_Allocate_Memory(&System_Memory,&(pFrame->m_pRGB),nWidth*nHeight*3,0))
return FALSE;
}
*(pFrame->m_pRGB + curP++) = R;
*(pFrame->m_pRGB + curP++) = G;
*(pFrame->m_pRGB + curP++) = B;
return TRUE;
}
BOOL InterLaceWriteToFrame(TFrame *pFrame,
int WritePos,
U8 R,
U8 G,
U8 B)
{
static int curP;
static int pass1;
static int pass2;
static int pass3;
static int pass4;
static int p1line;
static int p2line;
static int p3line;
static int p4line;
static int count;
int uWidth,nwHeight;
uWidth = pFrame->m_imageDescriptor.m_wWidth;
nwHeight = pFrame->m_imageDescriptor.m_wHeight;
if(WritePos == 0)
{
count = 0;
curP = 0;
pass1 = 1;
pass2 = 0;
pass3 = 0;
pass4 = 0;
p1line = 0;
p2line = 4;
p3line = 2;
p4line = 1;
if(NU_SUCCESS != NU_Allocate_Memory(&System_Memory,&(pFrame->m_pRGB),uWidth*nwHeight*3,0))
return FALSE;
}
if(pass1){
*(pFrame->m_pRGB + p1line*uWidth*3 + curP++) = R;
*(pFrame->m_pRGB + p1line*uWidth*3 + curP++) = G;
*(pFrame->m_pRGB + p1line*uWidth*3 + curP++) = B;
if(curP == uWidth*3){
p1line += 8;
curP = 0;
}
if(p1line >= nwHeight){
pass2 = 1;
pass1 = 0;
p2line = 4;
curP = 0;
return TRUE;
}
}
if(pass2){
*(pFrame->m_pRGB + p2line*uWidth*3 + curP++) = R;
*(pFrame->m_pRGB + p2line*uWidth*3 + curP++) = G;
*(pFrame->m_pRGB + p2line*uWidth*3 + curP++) = B;
if(curP == uWidth*3){
p2line += 8;
curP = 0;
}
if(p2line >= nwHeight){
pass3 = 1;
pass2 = 0;
p3line = 2;
curP = 0;
return TRUE;
}
}
if(pass3){
*(pFrame->m_pRGB + p3line*uWidth*3 + curP++) = R;
*(pFrame->m_pRGB + p3line*uWidth*3 + curP++) = G;
*(pFrame->m_pRGB + p3line*uWidth*3 + curP++) = B;
if(curP == uWidth*3){
p3line += 4;
curP = 0;
}
if(p3line >= nwHeight){
pass4 = 1;
pass3 = 0;
p4line = 1;
curP = 0;
return TRUE;
}
}
if(pass4){
*(pFrame->m_pRGB + p4line*uWidth*3 + curP++) = R;
*(pFrame->m_pRGB + p4line*uWidth*3 + curP++) = G;
*(pFrame->m_pRGB + p4line*uWidth*3 + curP++) = B;
if(curP == uWidth*3){
p4line += 2;
curP = 0;
}
if(p4line >= nwHeight){
return TRUE;
}
}
return TRUE;
}
BOOL Large_SubDrawFrameRGB(TImage *pImage,
int curFrame,
int ClockWise,
int deltaH,int deltaW,
int LeftX,
int TopY,
int nWidth,
int nHeight)
{
int i,j,tag,flag = 0;
BYTE value;
BYTE thisRGB;
BYTE *pRGB,R,G,B;
int curX,curY,temp;
int height,width;
int offX,offY;
offX = pImage->m_Frame.m_imageDescriptor.m_wLeftPos;
offY = pImage->m_Frame.m_imageDescriptor.m_wTopPos;
height = pImage->m_Frame.m_imageDescriptor.m_wHeight;
width = pImage->m_Frame.m_imageDescriptor.m_wWidth;
pRGB = pImage->m_Frame.m_pRGB;
if(curFrame == 0){
ClockWise = 0;
}
if(ClockWise || (height > width && (height > nHeight || width > nWidth))){
ClockWise = 1;
}
offX -= deltaW;
offY -= deltaH;
for(i=0;i<height;i++)
{
for(j=0;j<width;j++)
{
curX = LeftX+offX + j;
curY = TopY+offY + i;
if(height > width && (height > nHeight || width > nWidth) || ClockWise){
temp = nWidth + LeftX -1 - curY;
curY = curX;
curX = temp;
}
if(curX<LeftX || curX>=nWidth+LeftX|| curY<TopY || curY>=nHeight+TopY){
pRGB++;
continue;
}
/* thisRGB = *pRGB;
FillDot( curX,curY,thisRGB>>4); */
pRGB += 3;
PutPixel(curX,curY,*pRGB,*(pRGB+1),*(pRGB+2));
}
}
StnRefresh();
return TRUE;
}
BOOL Large_DrawFrameRGB(TImage *pImage,
int curFrame,
int LeftX,
int TopY,
int nWidth,
int nHeight)
{
static int ClockWise,GreatH,GreatW,cGreatH,cGreatW,deltaH,deltaW,lastDisposal;
static RECT lastR,curR;
int i,j,k,l,tag,flag=0;
BYTE tmp,value;
BYTE thisRGB,lastRGB,tranRGB,backRGB;
BYTE tR,tG,tB,bR,bG,bB,R,G,B;
BYTE *pRGB;
int curX,curY,temp;
int height,width;
int offX,offY;
int RestoreTag = 0,once = 1;
offX = pImage->m_Frame.m_imageDescriptor.m_wLeftPos;
offY = pImage->m_Frame.m_imageDescriptor.m_wTopPos;
height = pImage->m_Frame.m_imageDescriptor.m_wHeight;
width = pImage->m_Frame.m_imageDescriptor.m_wWidth;
pRGB = pImage->m_Frame.m_pRGB;
GetRGB( pImage, &(pImage->m_Frame), NULL, pImage->m_Frame.m_controlExt.m_cTColorIndex, &tR,&tG,&tB);
if(curFrame == 0){
ClockWise = 0;
GreatH = 0;
GreatW = 0;
cGreatH = 0;
cGreatW = 0;
deltaH = 0;
deltaW = 0;
lastDisposal = 0;
if(ClockWise || (height > width && height > nHeight)){
ClockWise = 1;
}
if(!ClockWise && height>nHeight){
GreatH = 1;
deltaH = (height -nHeight) / 2;
}
if(!ClockWise && width>nWidth){
GreatW = 1;
deltaW = (width - nWidth) / 2;
}
if(ClockWise && height >nWidth){
cGreatH =1;
deltaH = (height -nWidth) / 2;
}
if( ClockWise && width >nHeight){
cGreatW = 1;
deltaW = (width - nHeight) / 2;
}
}
if(GreatH){
offY -= deltaH;
}
if(GreatW){
offX -= deltaW;
}
if(cGreatH){
offY -= deltaH;
}
if(cGreatW){
offX -= deltaW;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -