?? gif.c
字號(hào):
/*
The Application Extension contains application-specific information;
it conforms with the extension block syntax, as described below,
and its block label is 0xFF.
*/
case 0xff:
{
int loop;
/*
Read Netscape Loop extension.
*/
loop = OP_FALSE;
if (ReadBlobBlock(image, pp) != 0)
{
header = *pp;
loop = !LocaleNCompare((char *) header, "NETSCAPE2.0", 11);
}
while (ReadBlobBlock(image, pp) != 0)
{
header = *pp;
if (loop)
{
iterations = (header[2] << 8) | header[1];
}
}
break;
}
default:
{
while (ReadBlobBlock(image, pp) != 0) header = *pp;
break;
}
}
}
if (c != ',') /* 0x2C */
{
continue;
}
if (image_count != 0)
{
/*
Allocate next image structure.
*/
AllocateNextImage(image);
if (image->next == (Image *) OP_NULL)
{
return((Image *) OP_NULL);
}
image = image->next;
}
image_count++;
/*
Read image attributes.
*/
image->page.x = ReadBlobLSBShort(image);
image->page.y = ReadBlobLSBShort(image);
image->columns = ReadBlobLSBShort(image);
image->rows = ReadBlobLSBShort(image);
image->depth = 8;
flag = ReadBlobByte(image);
image->interlace = BitSet(flag,0x40) ? PlaneInterlace : NoInterlace;
image->colors = !BitSet(flag,0x80) ? global_colors : 1 << ((flag & 0x07)+1);
if (opacity >= (long) image->colors)
{
image->colors = opacity+1;
}
image->trans_flag = trans_flag;
image->delay = delay;
image->dispose = dispose;
image->iterations = iterations;
image->matte = opacity >= 0;
delay = 0;
dispose = 0;
if ((image->columns == 0) || (image->rows == 0))
{
if(image != inputimage)
{
DestroyImage(image);
}
return OP_NULL;
}
image->pixeldata = (PixelPacket *)outbuf;
/*
Inititialize colormap.
*/
if (!AllocateImageColormap(image, image->colors))
{
if(image != inputimage)
{
DestroyImage(image);
}
return OP_NULL;
}
if (!BitSet(flag, 0x80))
{
/*
Use global colormap.
*/
p = global_colormap;
for (i=0; i < (long) image->colors; i++)
{
image->colormap[i].red = Upscale(*p++);
image->colormap[i].green = Upscale(*p++);
image->colormap[i].blue = Upscale(*p++);
}
image->background_color = image->colormap[Min(background, image->colors-1)];
}
else
{
/*
Read local colormap.
*/
(void) ReadBlob(image, 3*image->colors, pp);
p = *pp;
for (i=0; i < (long) image->colors; i++)
{
image->colormap[i].red = Upscale(*p++);
image->colormap[i].green = Upscale(*p++);
image->colormap[i].blue = Upscale(*p++);
}
}
/*
Decode image.
*/
/* decide if we need to decode */
if(!skipdecoding)
{
status = DecodeGIFImage(image,opacity,func);
if (status == OP_FALSE)
{
if(image != inputimage)
{
DestroyImage(image);
}
return OP_NULL;
}
if(saveimage != OP_NULL)
{
saveimage(image);
}
}
else if (only_info)
{
status = skip_decoding_datablock(image);
if (status == OP_FALSE)
{
if(image != inputimage)
{
DestroyImage(image);
}
return OP_NULL;
}
}
return(image);
}
/*
* 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 ReadGIFFrame() \n" );
}
if(image != inputimage)
{
DestroyImage(image);
}
return OP_NULL;
}
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% R e a d G I F H e a d e r %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
Image *ReadGIFHeader
(
const Image *image_info
)
{
unsigned char c;
unsigned char *magick;
unsigned char *tp;
unsigned char **pp;
unsigned int count;
int status;
Image *image;
pp = &tp;
/*
Open image file.
*/
image = AllocateImage(image_info);
/*
Investigate about status(OpenBlob()) routine
Always return OP_TRUE now in the OpenBlob().
*/
status = OpenBlob(image, ReadBinaryType);
if (status == OP_FALSE)
{
DestroyImage(image);
return OP_NULL;
}
/*
6 -> for read the file format(GIF87a or GIF89a -> first six character)
Determine if this is a GIF file.
*/
count = ReadBlob(image, 6, pp);
magick = *pp;
/* Neither GIF87, GIF89 */
if ((count == 0) || ((LocaleNCompare((char *) magick,"GIF87",5) != 0) &&
(LocaleNCompare((char *) magick,"GIF89",5) != 0)))
{
DestroyImage(image);
return OP_NULL;
}
global_colors = 0;
global_colormap = (unsigned char *) OP_NULL;
image->page.width = ReadBlobLSBShort(image);
image->page.height = ReadBlobLSBShort(image);
flag = ReadBlobByte(image);
/* background -> background color num of image in file */
background = ReadBlobByte(image);
c = ReadBlobByte(image); /* reserved */
/* c -> only GIF89a, c != 0 -> ratio of width and height (c+15)/64 */
/*
(flag & 0x07)+1 -> bit num of pallete
(1<<(flag>>4)+1) -> color bit num of source image
*/
global_colors = 1 << ((flag & 0x07)+1);
if (BitSet(flag, 0x80))
{
(void) ReadBlob(image, 3*global_colors, pp);
global_colormap = *pp;
}
delay = 0;
dispose = 0;
iterations = 0;
opacity = (-1);
image_count = 0;
trans_flag = OP_FALSE;
return image;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -