?? gif.c
字號:
///////////////////////////////////////////////////////////////////////////////
//
// gif.c
//
// DESCRIPTION
// Define gif decoding functions
//
//
///////////////////////////////////////////////////////////////////////////////
/*
Include declarations.
*/
#include "gifcommon.h"
#include "SP_include.h"
#define BitSet(byte,bit) (((byte) & (bit)) == (bit))
#define LSBFirstOrder(x,y) (((y) << 8) | (x))
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% D e c o d e I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Method DecodeImage uncompresses an image via GIF-coding.
%
% The format of the DecodeImage method is:
%
% unsigned int DecodeImage(Image *image,const long opacity)
%
% A description of each parameter follows:
%
% o status: Method DecodeImage returns True if all the pixels are
% uncompressed without error, otherwise False.
%
% o image: The address of a structure of type Image.
%
% o opacity: The colormap index associated with the transparent
% color.
%
%
*/
extern unsigned int DecodeGIFImage
(
Image *image,
const long opacity,
OP_BOOLEAN func(OP_UINT16 x, OP_UINT16 y)
);
extern unsigned int skip_decoding_datablock
(
Image *image
);
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
+ R e a d B l o b B l o c k %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Method ReadBlobBlock reads data from the image file and returns it. The
% amount of data is determined by first reading a count byte. The number
% or bytes read is returned.
%
% The format of the ReadBlobBlock method is:
%
% unsigned int ReadBlobBlock(Image *image,unsigned char *data)
%
% A description of each parameter follows:
%
% o count: Method ReadBlobBlock returns the number of bytes read.
%
% o image: The image.
%
% o data: Specifies an area to place the information requested from
% the file.
%
%
*/
unsigned int ReadBlobBlock
(
Image *image,
unsigned char **data
)
{
size_t count;
unsigned char *block_count;
count = ReadBlob(image, 1, &block_count);
if (count == 0)
{
return(0);
}
return(ReadBlob(image, *block_count, data));
}
// global variables
// global colormap
static unsigned char *global_colormap;
// number of global colors
static unsigned int global_colors;
// image count
static unsigned int image_count;
// display delay in ms
static unsigned int delay;
// how to dispose the image;
static unsigned int dispose;
// number of iterations
static unsigned int iterations;
// opacity
static long opacity;
// background
static unsigned char background;
// flag
static unsigned char flag;
/* transparent flag */
static OP_BOOLEAN trans_flag = OP_FALSE;
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% R e a d G I F F r a m e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
Image *ReadGIFFrame
(
Image *image,
unsigned char *outbuf,
ImageSaveMethod saveimage,
OP_BOOLEAN skipdecoding,
OP_BOOLEAN only_info,
OP_BOOLEAN func(OP_UINT16 x, OP_UINT16 y)
)
{
unsigned char c;
unsigned char *header;
unsigned char *tp;
unsigned char **pp;
register unsigned char *p;
int status;
unsigned int count;
register long i;
Image *inputimage;
// save image pointer
inputimage = image;
pp = &tp;
for( ; ; )
{
count = ReadBlob(image, 1, pp);
c = (*pp)[0];
if (count == 0)
{
break;
}
if (c == ';') /* 0x3B */
{
break; /* terminator */
}
if (c == '!') /* 0x21 */
{
/*
GIF Extension block.
*/
count=ReadBlob(image, 1, pp);
c = (*pp)[0];
if (count == 0)
{
/*
* added DestoryImage because of
* remove the free momery routine in gifDecodeImage()
*/
if ( image->next != OP_NULL )
{
DestroyImage(image->next);
op_debug_msg(SP_DEBUG_GROUP_MMI, DEBUG_HIGH, "Image Decoder DestoryImage() in count == 0 \n" );
}
if(image != inputimage)
{
DestroyImage(image);
}
return OP_NULL;
}
switch (c)
{
/*
The Graphics Control Extension contains parameters used
when procssing a graphic rendering block.
The scope of this extension is the first graphic rendering block to follow.
The extension contains only one data sub-block.
*/
case 0xf9:
{
/*
Read Graphics Control extension.
*/
while (ReadBlobBlock(image, pp) != 0);
header = *pp;
dispose = header[0] >> 2;
delay = (header[2] << 8) | header[1];
if ((header[0] & 0x01) == 1)
{
trans_flag = OP_TRUE;
opacity = header[3];
}
else
{
trans_flag = OP_FALSE;
}
break;
}
case 0xfe:
{
/*
* remove to related comments code because violation of memory access
* char *comments;
*/
/* Read Comment extension. */
/*
* remove to related comments code because violation of memory access
* comments = AllocateString((char *) OP_NULL, image->getmemory);
*/
for ( ; ; )
{
count = ReadBlobBlock(image,pp);
/*
* remove to related comments code because violation of memory access
* header = *pp;
*/
if (count == 0)
{
break;
}
/*
* remove to related comments code because violation of memory access
* header[count] = '\0';
* (void) ConcatenateString(&comments, (const char *) header,
* image->getmemory, image->freememory);
*/
}
/*
* remove to related comments code because violation of memory access
* (void) SetImageAttribute(image, "comment", comments);
* image->freememory((void *) comments);
*/
break;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -