您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ DGifGetExtensionNext函数代码示例

51自学网 2021-06-01 20:21:33
  C++
这篇教程C++ DGifGetExtensionNext函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中DGifGetExtensionNext函数的典型用法代码示例。如果您正苦于以下问题:C++ DGifGetExtensionNext函数的具体用法?C++ DGifGetExtensionNext怎么用?C++ DGifGetExtensionNext使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了DGifGetExtensionNext函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: while

GifRecordType GIFAbstractDataset::FindFirstImage( GifFileType* hGifFile ){    GifRecordType RecordType = TERMINATE_RECORD_TYPE;    while( DGifGetRecordType(hGifFile, &RecordType) != GIF_ERROR           && RecordType != TERMINATE_RECORD_TYPE           && RecordType != IMAGE_DESC_RECORD_TYPE )    {        /* Skip extension records found before IMAGE_DESC_RECORD_TYPE */        if (RecordType == EXTENSION_RECORD_TYPE)        {            int nFunction;            GifByteType *pExtData = nullptr;            if (DGifGetExtension(hGifFile, &nFunction, &pExtData) == GIF_ERROR)                break;            while (pExtData != nullptr)            {                if (DGifGetExtensionNext(hGifFile, &pExtData) == GIF_ERROR)                    break;            }        }    }    return RecordType;}
开发者ID:hdfeos,项目名称:gdal,代码行数:25,


示例2: dGifGetExtension

value dGifGetExtension( value hdl ){  CAMLparam1(hdl);  CAMLlocal3(ext,exts,res);  CAMLlocal1(newres);  GifFileType *GifFile = (GifFileType*) hdl;  int func;  GifByteType *extData;  exts = Val_int(0);  if (DGifGetExtension(GifFile,&func, &extData) == GIF_ERROR){    failwith("DGifGetExtension");  }  while( extData != NULL ){    ext= alloc_string(extData[0]);    memcpy(String_val(ext), &extData[1], extData[0]);    newres = alloc_small(2,0);    caml_modify_field(newres, 0, ext);    caml_modify_field(newres, 1, exts);    exts= newres;    DGifGetExtensionNext(GifFile, &extData);  }  res = alloc_small(2,0);  caml_modify_field(res,0, Val_int(func));  caml_modify_field(res,1, exts);  CAMLreturn(res);}
开发者ID:philipdexter,项目名称:camlimages,代码行数:31,


示例3: readExtensions

static int readExtensions(int ExtFunction, GifByteType *ExtData, GifInfo *info) {    if (ExtData == NULL)        return GIF_OK;    if (ExtFunction == GRAPHICS_EXT_FUNC_CODE) {        GraphicsControlBlock *GCB = &info->controlBlock[info->gifFilePtr->ImageCount];        if (DGifExtensionToGCB(ExtData[0], ExtData + 1, GCB) == GIF_ERROR)            return GIF_ERROR;        GCB->DelayTime = GCB->DelayTime > 1 ? GCB->DelayTime * 10 : DEFAULT_FRAME_DURATION_MS;    }    else if (ExtFunction == COMMENT_EXT_FUNC_CODE) {        if (getComment(ExtData, info) == GIF_ERROR) {            info->gifFilePtr->Error = D_GIF_ERR_NOT_ENOUGH_MEM;            return GIF_ERROR;        }    }    else if (ExtFunction == APPLICATION_EXT_FUNC_CODE) {        char const *string = (char const *) (ExtData + 1);        if (strncmp("NETSCAPE2.0", string, ExtData[0]) == 0            || strncmp("ANIMEXTS1.0", string, ExtData[0]) == 0) {            if (DGifGetExtensionNext(info->gifFilePtr, &ExtData,                                     &ExtFunction) == GIF_ERROR)                return GIF_ERROR;            if (ExtData[0] == 3 && ExtData[1] == 1) {                info->loopCount = (uint_fast16_t) (ExtData[2] + (ExtData[3] << 8));            }        }    }    return GIF_OK;}
开发者ID:bearprada,项目名称:android-gif-drawable,代码行数:30,


示例4: gif_fileread

static GifRecordTypegif_fileread(struct gif_state *h){    GifRecordType RecordType;    GifByteType *Extension;    int ExtCode, rc;    const char *type;    for (;;) {	if (GIF_ERROR == DGifGetRecordType(h->gif,&RecordType)) {	    if (FbiStuff::fim_filereading_debug())		FIM_FBI_PRINTF("gif: DGifGetRecordType failed/n");	    PrintGifError();	    return (GifRecordType)-1;	}	switch (RecordType) {	case IMAGE_DESC_RECORD_TYPE:	    if (FbiStuff::fim_filereading_debug())		FIM_FBI_PRINTF("gif: IMAGE_DESC_RECORD_TYPE found/n");	    return RecordType;	case EXTENSION_RECORD_TYPE:	    if (FbiStuff::fim_filereading_debug())		FIM_FBI_PRINTF("gif: EXTENSION_RECORD_TYPE found/n");	    for (rc = DGifGetExtension(h->gif,&ExtCode,&Extension);		 NULL != Extension;		 rc = DGifGetExtensionNext(h->gif,&Extension)) {		if (rc == GIF_ERROR) {		    if (FbiStuff::fim_filereading_debug())			FIM_FBI_PRINTF("gif: DGifGetExtension failed/n");		    PrintGifError();		    return (GifRecordType)-1;		}		if (FbiStuff::fim_filereading_debug()) {		    switch (ExtCode) {		    case COMMENT_EXT_FUNC_CODE:     type="comment";   break;		    case GRAPHICS_EXT_FUNC_CODE:    type="graphics";  break;		    case PLAINTEXT_EXT_FUNC_CODE:   type="plaintext"; break;		    case APPLICATION_EXT_FUNC_CODE: type="appl";      break;		    default:                        type="???";       break;		    }		    FIM_FBI_PRINTF("gif: extcode=0x%x [%s]/n",ExtCode,type);		}	    }	    break;	case TERMINATE_RECORD_TYPE:	    if (FbiStuff::fim_filereading_debug())		FIM_FBI_PRINTF("gif: TERMINATE_RECORD_TYPE found/n");	    return RecordType;	default:	    if (FbiStuff::fim_filereading_debug())		FIM_FBI_PRINTF("gif: unknown record type [%d]/n",RecordType);	    return (GifRecordType)-1;	}    }}
开发者ID:phantasea,项目名称:fim,代码行数:55,


示例5: DGifGetExtension

/****************************************************************************** * Get an extension block (see GIF manual) from gif file. This routine only * returns the first data block, and DGifGetExtensionNext should be called * after this one until NULL extension is returned. * The Extension should NOT be freed by the user (not dynamically allocated). * Note it is assumed the Extension desc. header ('!') has been read. *****************************************************************************/static intDGifGetExtension(GifFileType * GifFile,                 int *ExtCode,                 GifByteType ** Extension) {    GifByteType Buf;    if (READ(GifFile, &Buf, 1) != 1) {        return GIF_ERROR;    }    *ExtCode = Buf;    return DGifGetExtensionNext(GifFile, Extension);}
开发者ID:hoangduit,项目名称:reactos,代码行数:21,


示例6: GIFReadLoopCount

int GIFReadLoopCount(GifFileType* const gif, GifByteType** const buf,                     int* const loop_count) {  assert(!memcmp(*buf + 1, "NETSCAPE2.0", 11) ||         !memcmp(*buf + 1, "ANIMEXTS1.0", 11));  if (DGifGetExtensionNext(gif, buf) == GIF_ERROR) {    return 0;  }  if (*buf == NULL) {    return 0;  // Loop count sub-block missing.  }  if ((*buf)[0] < 3 || (*buf)[1] != 1) {    return 0;   // wrong size/marker  }  *loop_count = (*buf)[2] | ((*buf)[3] << 8);  return 1;}
开发者ID:2025Labs,项目名称:iOS,代码行数:16,


示例7: GIFReadMetadata

int GIFReadMetadata(GifFileType* const gif, GifByteType** const buf,                    WebPData* const metadata) {  const int is_xmp = !memcmp(*buf + 1, "XMP DataXMP", 11);  const int is_icc = !memcmp(*buf + 1, "ICCRGBG1012", 11);  assert(is_xmp || is_icc);  (void)is_icc;  // silence unused warning.  // Construct metadata from sub-blocks.  // Usual case (including ICC profile): In each sub-block, the  // first byte specifies its size in bytes (0 to 255) and the  // rest of the bytes contain the data.  // Special case for XMP data: In each sub-block, the first byte  // is also part of the XMP payload. XMP in GIF also has a 257  // byte padding data. See the XMP specification for details.  while (1) {    WebPData subblock;    const uint8_t* tmp;    if (DGifGetExtensionNext(gif, buf) == GIF_ERROR) {      return 0;    }    if (*buf == NULL) break;  // Finished.    subblock.size = is_xmp ? (*buf)[0] + 1 : (*buf)[0];    assert(subblock.size > 0);    subblock.bytes = is_xmp ? *buf : *buf + 1;    // Note: We store returned value in 'tmp' first, to avoid    // leaking old memory in metadata->bytes on error.    tmp = (uint8_t*)realloc((void*)metadata->bytes,                            metadata->size + subblock.size);    if (tmp == NULL) {      return 0;    }    memcpy((void*)(tmp + metadata->size),           subblock.bytes, subblock.size);    metadata->bytes = tmp;    metadata->size += subblock.size;  }  if (is_xmp) {    // XMP padding data is 0x01, 0xff, 0xfe ... 0x01, 0x00.    const size_t xmp_pading_size = 257;    if (metadata->size > xmp_pading_size) {      metadata->size -= xmp_pading_size;    }  }  return 1;}
开发者ID:2025Labs,项目名称:iOS,代码行数:44,


示例8: fh_gif_getsize

int fh_gif_getsize(const char *name,int *x,int *y, int /*wanted_width*/, int /*wanted_height*/){	int px,py;	GifFileType *gft;	GifByteType *extension;	int extcode;	GifRecordType rt;#if GIFLIB_MAJOR >= 5	int error;	gft=DGifOpenFileName(name, &error);#else	gft=DGifOpenFileName(name);#endif	if(gft==NULL) gflush;	do	{		if(DGifGetRecordType(gft,&rt) == GIF_ERROR) grflush;		switch(rt)		{			case IMAGE_DESC_RECORD_TYPE:				if(DGifGetImageDesc(gft)==GIF_ERROR) grflush;				px=gft->Image.Width;				py=gft->Image.Height;				*x=px; *y=py;				DGIFCLOSEFILE(gft);				return(FH_ERROR_OK);				break;			case EXTENSION_RECORD_TYPE:				if(DGifGetExtension(gft,&extcode,&extension)==GIF_ERROR)	grflush;				while(extension!=NULL)					if(DGifGetExtensionNext(gft,&extension)==GIF_ERROR) grflush;				break;			default:				break;		}	}	while( rt!= TERMINATE_RECORD_TYPE );	DGIFCLOSEFILE(gft);	return(FH_ERROR_FORMAT);}
开发者ID:j00zek,项目名称:j00zeks-neutrino-mp-cst-next,代码行数:42,


示例9: DGifGetExtension

static int DGifGetExtension(GifFileType * GifFile, int *ExtCode, GifByteType ** Extension){	GifByteType Buf;	GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;	if (!IS_READABLE(Private))	{		_GifError = D_GIF_ERR_NOT_READABLE;		return GIF_ERROR;	}	if (READ(GifFile, &Buf, 1) != 1)	{		_GifError = D_GIF_ERR_READ_FAILED;		return GIF_ERROR;	}	*ExtCode = Buf;	return DGifGetExtensionNext(GifFile, Extension);}
开发者ID:Gamer125,项目名称:wiibrowser,代码行数:20,


示例10: block

/****************************************************************************** Get an extension block (see GIF manual) from GIF file. This routine only returns the first data block, and DGifGetExtensionNext should be called after this one until NULL extension is returned. The Extension should NOT be freed by the user (not dynamically allocated). Note it is assumed the Extension description header has been read.******************************************************************************/intDGifGetExtension(GifFileType *GifFile, int *ExtCode, GifByteType **Extension){    GifByteType Buf;    GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;    if (!IS_READABLE(Private)) {        /* This file was NOT open for reading: */        GifFile->Error = D_GIF_ERR_NOT_READABLE;        return GIF_ERROR;    }    if (READ(GifFile, &Buf, 1) != 1) {        GifFile->Error = D_GIF_ERR_READ_FAILED;        return GIF_ERROR;    }    *ExtCode = Buf;    return DGifGetExtensionNext(GifFile, Extension);}
开发者ID:9miao,项目名称:CrossApp,代码行数:27,


示例11: fh_gif_getsize

int fh_gif_getsize(char *name,int *x,int *y){    int px,py;    GifFileType *gft;    GifByteType *extension;    int extcode;    GifRecordType rt;    gft=DGifOpenFileName(name);    if(gft==NULL) gflush;    do    {	if(DGifGetRecordType(gft,&rt) == GIF_ERROR) grflush;	switch(rt)	{	    case IMAGE_DESC_RECORD_TYPE:		if(DGifGetImageDesc(gft)==GIF_ERROR) grflush;		px=gft->Image.Width;		py=gft->Image.Height;		*x=px; *y=py;		DGifCloseFile(gft);		return(FH_ERROR_OK);		break;	    case EXTENSION_RECORD_TYPE:		if(DGifGetExtension(gft,&extcode,&extension)==GIF_ERROR) grflush;		while(extension!=NULL)		    if(DGifGetExtensionNext(gft,&extension)==GIF_ERROR) grflush;		break;	    default:		break;	}      }    while( rt!= TERMINATE_RECORD_TYPE );    DGifCloseFile(gft);    return(FH_ERROR_FORMAT);}
开发者ID:Pivosgroup,项目名称:aml-original-linux-buildroot,代码行数:37,


示例12: main

//.........这里部分代码省略.........	    QuitGifError(GifFileIn, GifFileOut);	switch (RecordType) {	    case IMAGE_DESC_RECORD_TYPE:		if (DGifGetImageDesc(GifFileIn) == GIF_ERROR)		    QuitGifError(GifFileIn, GifFileOut);		if ((++ImageNum == ImageN) && ImageNFlag) {		    /* We are suppose to modify this image color map, do it: */		    GifFileIn->SColorMap =ModifyColorMap(GifFileIn->SColorMap);		    if (!HasGIFOutput) {			/* We can quit here, as we have the color map: */			if (GifFileIn != NULL) DGifCloseFile(GifFileIn);			fclose(ColorFile);			exit(EXIT_SUCCESS);		    }		}		if (HasGIFOutput)		    if (EGifPutImageDesc(GifFileOut,			GifFileIn->Image.Left, GifFileIn->Image.Top,			GifFileIn->Image.Width, GifFileIn->Image.Height,			GifFileIn->Image.Interlace,			GifFileIn->Image.ColorMap) == GIF_ERROR)			QuitGifError(GifFileIn, GifFileOut);		if (!TranslateFlag || (ImageNFlag && (ImageN != ImageNum)))		{		    /* Now read image itself in decoded form as we don't */		    /* really care what we have there, and this is much  */		    /* faster.						 */		    if (DGifGetCode(GifFileIn, &CodeSize, &CodeBlock) == GIF_ERROR)			QuitGifError(GifFileIn, GifFileOut);		    if (HasGIFOutput)			if (EGifPutCode(GifFileOut, CodeSize, CodeBlock) == GIF_ERROR)			    QuitGifError(GifFileIn, GifFileOut);		    while (CodeBlock != NULL) {			if (DGifGetCodeNext(GifFileIn, &CodeBlock) == GIF_ERROR)			    QuitGifError(GifFileIn, GifFileOut);			if (HasGIFOutput)			    if (EGifPutCodeNext(GifFileOut, CodeBlock) == GIF_ERROR)				QuitGifError(GifFileIn, GifFileOut);		    }		}		else	/* we need to mung pixels intices */		{		    int	i;		    register GifPixelType *cp;		    GifPixelType *Line			= (GifPixelType *) malloc(GifFileIn->Image.Width *						  sizeof(GifPixelType));		    for (i = 0; i < GifFileIn->Image.Height; i++) {			if (DGifGetLine(GifFileIn, Line,GifFileIn->Image.Width)			    == GIF_ERROR) {			    QuitGifError(GifFileIn, GifFileOut);			}			/* translation step goes here */			for (cp = Line; cp < Line+GifFileIn->Image.Width; cp++)			    *cp = Translation[*cp];			if (EGifPutLine(GifFileOut,					Line, GifFileIn->Image.Width)			    == GIF_ERROR) {			    QuitGifError(GifFileIn, GifFileOut);			}		    }		    free((char *) Line);		}		break;	    case EXTENSION_RECORD_TYPE:		/* Skip any extension blocks in file: */		if (DGifGetExtension(GifFileIn, &ExtCode, &Extension) == GIF_ERROR)		    QuitGifError(GifFileIn, GifFileOut);		if (HasGIFOutput)		    if (EGifPutExtension(GifFileOut, ExtCode, Extension[0],							Extension) == GIF_ERROR)			QuitGifError(GifFileIn, GifFileOut);		/* No support to more than one extension blocks, so discard: */		while (Extension != NULL) {		    if (DGifGetExtensionNext(GifFileIn, &Extension) == GIF_ERROR)			QuitGifError(GifFileIn, GifFileOut);		}		break;	    case TERMINATE_RECORD_TYPE:		break;	    default:		    /* Should be traps by DGifGetRecordType. */		break;	}    }    while (RecordType != TERMINATE_RECORD_TYPE);    if (DGifCloseFile(GifFileIn) == GIF_ERROR)	QuitGifError(GifFileIn, GifFileOut);    if (HasGIFOutput)	if (EGifCloseFile(GifFileOut) == GIF_ERROR)	    QuitGifError(GifFileIn, GifFileOut);    return 0;}
开发者ID:BOTCrusher,项目名称:sagetv,代码行数:101,


示例13: DDGifSlurp

void DDGifSlurp(GifInfo *info, bool shouldDecode) {    GifRecordType RecordType;    GifByteType *ExtData;    int codeSize;    int ExtFunction;    do {        if (DGifGetRecordType(info->gifFilePtr, &RecordType) == GIF_ERROR)            return;        switch (RecordType) {            case IMAGE_DESC_RECORD_TYPE:                if (DGifGetImageDesc(info->gifFilePtr, !shouldDecode) == GIF_ERROR)                    return;                const uint_fast16_t requiredScreenWidth = info->gifFilePtr->Image.Left + info->gifFilePtr->Image.Width;                const uint_fast16_t requiredScreenHeight = info->gifFilePtr->Image.Top + info->gifFilePtr->Image.Height;                if (requiredScreenWidth > info->gifFilePtr->SWidth || requiredScreenHeight > info->gifFilePtr->SHeight) {                    if (shouldDecode) {                        void *tmpRasterBits = realloc(info->rasterBits,                                                      requiredScreenWidth * requiredScreenHeight * sizeof(GifPixelType));                        if (tmpRasterBits == NULL) {                            info->gifFilePtr->Error = D_GIF_ERR_NOT_ENOUGH_MEM;                            return;                        }                        info->rasterBits = tmpRasterBits;                    }                    else {                        info->gifFilePtr->SWidth = requiredScreenWidth;                        info->gifFilePtr->SHeight = requiredScreenHeight;                    }                }                if (shouldDecode) {                    if (info->gifFilePtr->Image.Interlace) {                        uint_fast16_t i, j;                        /*                         * The way an interlaced image should be read -                         * offsets and jumps...                         */                        uint_fast8_t InterlacedOffset[] = {0, 4, 2, 1};                        uint_fast8_t InterlacedJumps[] = {8, 8, 4, 2};                        /* Need to perform 4 passes on the image */                        for (i = 0; i < 4; i++)                            for (j = InterlacedOffset[i]; j < info->gifFilePtr->Image.Height; j += InterlacedJumps[i]) {                                if (DGifGetLine(info->gifFilePtr, info->rasterBits + j * info->gifFilePtr->Image.Width,                                                info->gifFilePtr->Image.Width) == GIF_ERROR)                                    return;                            }                    }                    else {                        if (DGifGetLine(                                info->gifFilePtr, info->rasterBits,                                info->gifFilePtr->Image.Width * info->gifFilePtr->Image.Height) == GIF_ERROR)                            return;                    }                    return;                }                else {                    if (DGifGetCode(info->gifFilePtr, &codeSize, &ExtData) == GIF_ERROR)                        return;                    while (ExtData != NULL) {                        if (DGifGetCodeNext(info->gifFilePtr, &ExtData) == GIF_ERROR)                            return;                    }                }                break;            case EXTENSION_RECORD_TYPE:                if (DGifGetExtension(info->gifFilePtr, &ExtFunction, &ExtData) == GIF_ERROR)                    return;                if (!shouldDecode) {                    GraphicsControlBlock *tmpInfos = realloc(info->controlBlock,                                                             (info->gifFilePtr->ImageCount + 1) *                                                             sizeof(GraphicsControlBlock));                    if (tmpInfos == NULL) {                        info->gifFilePtr->Error = D_GIF_ERR_NOT_ENOUGH_MEM;                        return;                    }                    info->controlBlock = tmpInfos;                    info->controlBlock[info->gifFilePtr->ImageCount].DelayTime = DEFAULT_FRAME_DURATION_MS;                    if (readExtensions(ExtFunction, ExtData, info) == GIF_ERROR)                        return;                }                while (ExtData != NULL) {                    if (DGifGetExtensionNext(info->gifFilePtr, &ExtData,                                             &ExtFunction) == GIF_ERROR)                        return;                    if (!shouldDecode) {                        if (readExtensions(ExtFunction, ExtData, info) == GIF_ERROR)                            return;                    }                }                break;            case TERMINATE_RECORD_TYPE:                break;            default: /* Should be trapped by DGifGetRecordType */                break;//.........这里部分代码省略.........
开发者ID:bearprada,项目名称:android-gif-drawable,代码行数:101,


示例14: get_gif_saved_images

intget_gif_saved_images( GifFileType *gif, int subimage, SavedImage **ret, int *ret_images  ){    GifRecordType RecordType;    GifByteType *ExtData;    SavedImage temp_save;	int curr_image = 0, ret_count = *ret_images ;	int status = GIF_OK;	memset( &temp_save, 0x00, sizeof( temp_save ) );	do	{		if ( (status = DGifGetRecordType(gif, &RecordType)) == GIF_ERROR)		{			break;		}		switch (RecordType)		{	    	case IMAGE_DESC_RECORD_TYPE:				if ((status = get_gif_image_desc(gif, &temp_save)) == GIF_OK)				{					int size = temp_save.ImageDesc.Width*temp_save.ImageDesc.Height ;					temp_save.RasterBits = realloc( temp_save.RasterBits, size );					status = DGifGetLine(gif, (unsigned char*)temp_save.RasterBits, size);					if (status == GIF_OK)					{						if( curr_image == subimage || subimage < 0 )						{							append_gif_saved_image( &temp_save, ret, &(ret_count));						}					}					++curr_image ;				}				break;	    	case EXTENSION_RECORD_TYPE:				status = DGifGetExtension(gif,&temp_save.Function,&ExtData);				while (ExtData != NULL && status == GIF_OK )				{            		/* Create an extension block with our data */            		if ((status = AddExtensionBlock(&temp_save, ExtData[0], (char*)&(ExtData[1]))) == GIF_OK)				    	status = DGifGetExtensionNext(gif, &ExtData);            		temp_save.Function = 0;				}				break;	    	case TERMINATE_RECORD_TYPE:				break;	    	default:	/* Should be trapped by DGifGetRecordType */				break;		}    }while( status == GIF_OK && RecordType != TERMINATE_RECORD_TYPE);/*	if( status == GIF_OK && *ret == NULL )		append_gif_saved_image( &temp_save, ret, &(ret_count));	else*/	free_gif_saved_image( &temp_save, True );	*ret_images = ret_count ;    return status;}
开发者ID:Remmy,项目名称:afterstep,代码行数:63,


示例15: DGifCloseFile

CPLErr BIGGIFDataset::ReOpen(){/* -------------------------------------------------------------------- *//*      If the file is already open, close it so we can restart.        *//* -------------------------------------------------------------------- */    if( hGifFile != NULL )        DGifCloseFile( hGifFile );/* -------------------------------------------------------------------- *//*      If we are actually reopening, then we assume that access to     *//*      the image data is not strictly once through sequential, and     *//*      we will try to create a working database in a temporary         *//*      directory to hold the image as we read through it the second    *//*      time.                                                           *//* -------------------------------------------------------------------- */    if( hGifFile != NULL )    {        GDALDriver *poGTiffDriver = (GDALDriver*) GDALGetDriverByName("GTiff");                if( poGTiffDriver != NULL )        {            /* Create as a sparse file to avoid filling up the whole file */            /* while closing and then destroying this temporary dataset */            const char* apszOptions[] = { "COMPRESS=LZW", "SPARSE_OK=YES", NULL };            CPLString osTempFilename = CPLGenerateTempFilename("biggif");            osTempFilename += ".tif";            poWorkDS = poGTiffDriver->Create( osTempFilename,                                               nRasterXSize, nRasterYSize, 1,                                               GDT_Byte, const_cast<char**>(apszOptions));        }    }/* -------------------------------------------------------------------- *//*      Open                                                            *//* -------------------------------------------------------------------- */    VSIFSeekL( fp, 0, SEEK_SET );    nLastLineRead = -1;#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5    int nError;    hGifFile = DGifOpen( fp, VSIGIFReadFunc, &nError );#else    hGifFile = DGifOpen( fp, VSIGIFReadFunc );#endif    if( hGifFile == NULL )    {        CPLError( CE_Failure, CPLE_OpenFailed,                   "DGifOpen() failed.  Perhaps the gif file is corrupt?/n" );        return CE_Failure;    }/* -------------------------------------------------------------------- *//*      Find the first image record.                                    *//* -------------------------------------------------------------------- */    GifRecordType RecordType = TERMINATE_RECORD_TYPE;    while( DGifGetRecordType(hGifFile, &RecordType) != GIF_ERROR           && RecordType != TERMINATE_RECORD_TYPE           && RecordType != IMAGE_DESC_RECORD_TYPE )    {        /* Skip extension records found before IMAGE_DESC_RECORD_TYPE */        if (RecordType == EXTENSION_RECORD_TYPE)        {            int nFunction;            GifByteType *pExtData;            if (DGifGetExtension(hGifFile, &nFunction, &pExtData) == GIF_ERROR)                break;            while (pExtData != NULL)            {                if (DGifGetExtensionNext(hGifFile, &pExtData) == GIF_ERROR)                    break;            }        }    }    if( RecordType != IMAGE_DESC_RECORD_TYPE )    {        DGifCloseFile( hGifFile );        hGifFile = NULL;        CPLError( CE_Failure, CPLE_OpenFailed,                   "Failed to find image description record in GIF file." );        return CE_Failure;    }        if (DGifGetImageDesc(hGifFile) == GIF_ERROR)    {        DGifCloseFile( hGifFile );        hGifFile = NULL;        CPLError( CE_Failure, CPLE_OpenFailed,                   "Image description reading failed in GIF file." );        return CE_Failure;    }        return CE_None;//.........这里部分代码省略.........
开发者ID:afarnham,项目名称:gdal,代码行数:101,


示例16: sizeof

//.........这里部分代码省略.........		{			goto cleanup;		}		memcpy(ScreenBuffer[i], ScreenBuffer[0], Size);	}	*transparentColor = GIF_NOT_TRANSPARENT;	GifRecordType recordType;	do	{		if (DGifGetRecordType(gifFile, &recordType) == GIF_ERROR)		{			goto cleanup;		}		switch (recordType)		{			case IMAGE_DESC_RECORD_TYPE:			{				if (DGifGetImageDesc(gifFile) == GIF_ERROR)				{					goto cleanup;				}				row = gifFile->Image.Top;				col = gifFile->Image.Left;				width = gifFile->Image.Width;				height = gifFile->Image.Height;				GifPixelType *gifPixelType;				int location = 0;				if (gifFile->Image.Interlace)				{					for (i = 0; i < 4; i++)					{						for (j = row + InterlacedOffset[i]; j < row + height; j += InterlacedJumps[i])						{							gifPixelType = &ScreenBuffer[j][col];							if (DGifGetLine(gifFile, gifPixelType, width) == GIF_ERROR)							{								goto cleanup;							}							location += rowSize;						}					}				}				else				{					for (i = 0; i < height; i++)					{						if (DGifGetLine(gifFile, &ScreenBuffer[row++][col], width) == GIF_ERROR)						{							goto cleanup;						}					}				}				break;			}			case EXTENSION_RECORD_TYPE:			{				GifByteType *extension;				int extCode;				if (DGifGetExtension(gifFile, &extCode, &extension) == GIF_ERROR)				{					goto cleanup;				}				switch (extCode)				{					case GRAPHICS_EXT_FUNC_CODE:					{						int flag = extension[1];						*transparentColor = (flag & GIF_TRANSPARENT) ? extension[4] : GIF_NOT_TRANSPARENT;						break;					}				}				while (extension != NULL)				{					if (DGifGetExtensionNext(gifFile, &extension) == GIF_ERROR)					{						goto cleanup;					}				}				break;			}			case TERMINATE_RECORD_TYPE:			case UNDEFINED_RECORD_TYPE:			default:				break;		}	} while (recordType != TERMINATE_RECORD_TYPE);	goto finish;	cleanup: if (ScreenBuffer != NULL)	{		gif_free(ScreenBuffer);		ScreenBuffer = NULL;	}	finish: return ScreenBuffer;}
开发者ID:Gamer125,项目名称:wiibrowser,代码行数:101,


示例17: CPLError

GDALDataset *GIFDataset::Open( GDALOpenInfo * poOpenInfo ){    if( !Identify( poOpenInfo ) )        return NULL;    if( poOpenInfo->eAccess == GA_Update )    {        CPLError( CE_Failure, CPLE_NotSupported,                   "The GIF driver does not support update access to existing"                  " files./n" );        return NULL;    }/* -------------------------------------------------------------------- *//*      Open the file and ingest.                                       *//* -------------------------------------------------------------------- */    GifFileType 	*hGifFile;    VSILFILE                *fp;    int                  nGifErr;    fp = VSIFOpenL( poOpenInfo->pszFilename, "r" );    if( fp == NULL )        return NULL;    hGifFile = GIFAbstractDataset::myDGifOpen( fp, VSIGIFReadFunc );    if( hGifFile == NULL )    {        VSIFCloseL( fp );        CPLError( CE_Failure, CPLE_OpenFailed,                   "DGifOpen() failed for %s./n"                  "Perhaps the gif file is corrupt?/n",                  poOpenInfo->pszFilename );        return NULL;    }    /* The following code enables us to detect GIF datasets eligible */    /* for BIGGIF driver even with an unpatched giflib  */    /* -------------------------------------------------------------------- */    /*      Find the first image record.                                    */    /* -------------------------------------------------------------------- */    GifRecordType RecordType = TERMINATE_RECORD_TYPE;    while( DGifGetRecordType(hGifFile, &RecordType) != GIF_ERROR        && RecordType != TERMINATE_RECORD_TYPE        && RecordType != IMAGE_DESC_RECORD_TYPE )    {        /* Skip extension records found before IMAGE_DESC_RECORD_TYPE */        if (RecordType == EXTENSION_RECORD_TYPE)        {            int nFunction;            GifByteType *pExtData;            if (DGifGetExtension(hGifFile, &nFunction, &pExtData) == GIF_ERROR)                break;            while (pExtData != NULL)            {                if (DGifGetExtensionNext(hGifFile, &pExtData) == GIF_ERROR)                    break;            }        }    }    if( RecordType == IMAGE_DESC_RECORD_TYPE  &&        DGifGetImageDesc(hGifFile) != GIF_ERROR)    {        int width = hGifFile->SavedImages[0].ImageDesc.Width;        int height = hGifFile->SavedImages[0].ImageDesc.Height;        if ((double) width * (double) height > 100000000.0 )        {            CPLDebug( "GIF",                      "Due to limitations of the GDAL GIF driver we deliberately avoid/n"                      "opening large GIF files (larger than 100 megapixels).");            GIFAbstractDataset::myDGifCloseFile( hGifFile );            VSIFCloseL( fp );            return NULL;        }    }    GIFAbstractDataset::myDGifCloseFile( hGifFile );    VSIFSeekL( fp, 0, SEEK_SET);    hGifFile = GIFAbstractDataset::myDGifOpen( fp, VSIGIFReadFunc );    if( hGifFile == NULL )    {        VSIFCloseL( fp );        CPLError( CE_Failure, CPLE_OpenFailed,                   "DGifOpen() failed for %s./n"                  "Perhaps the gif file is corrupt?/n",                  poOpenInfo->pszFilename );        return NULL;    }    nGifErr = DGifSlurp( hGifFile );    if( nGifErr != GIF_OK || hGifFile->SavedImages == NULL )    {//.........这里部分代码省略.........
开发者ID:GeospatialDaryl,项目名称:VS2013__00_GDAL_111_x64,代码行数:101,


示例18: main

//.........这里部分代码省略.........		}		if (GifFile -> IInterlace) {		    /* Need to perform 4 passes on the images: */		    for (Count = i = 0; i < 4; i++)			for (j = Row + InterlacedOffset[i]; j < Row + Height;						 j += InterlacedJumps[i]) {			    GifQprintf("/b/b/b/b%-4d", Count++);			    if (DGifGetLine(GifFile,				&ScreenBuffer[MIN(j, MaximumScreenHeight)][Col],				Width) == GIF_ERROR) {				PrintGifError();				exit(-1);			    }			}		}		else {		    for (i = 0; i < Height; i++, Row++) {			GifQprintf("/b/b/b/b%-4d", i);			if (DGifGetLine(GifFile, &ScreenBuffer[MIN(Row, MaximumScreenHeight)][Col],				Width) == GIF_ERROR) {			    PrintGifError();			    MaximumScreenHeight = MIN(i - 1, MaximumScreenHeight);			}		    }		}		break;	    case EXTENSION_RECORD_TYPE:		/* Skip any extension blocks in file: */		if (DGifGetExtension(GifFile, &ExtCode, &Extension) == GIF_ERROR) {		    PrintGifError();		    exit(-1);		}		while (Extension != NULL) {		    if (DGifGetExtensionNext(GifFile, &Extension) == GIF_ERROR) {			PrintGifError();			exit(-1);		    }		}		break;	    case TERMINATE_RECORD_TYPE:		break;	    default:		    /* Should be traps by DGifGetRecordType. */		break;	}    }    while (RecordType != TERMINATE_RECORD_TYPE);    /* Lets display it - set the global variables required and do it: */    BackGround = GifFile -> SBackGroundColor;    ColorMap = (GifFile -> IColorMap ? GifFile -> IColorMap :				       GifFile -> SColorMap);    ColorMapSize = 1 << (GifFile -> IColorMap ? GifFile -> IBitsPerPixel :						GifFile -> SBitsPerPixel);    gettextinfo(&TextInfo);	     /* Save current mode so we can recover. */    initgraph(&GraphDriver, &GraphMode, BGIPath);    if (graphresult() != grOk)	 	       /* Error occured during init. */	GIF_EXIT("Graphics System Error, failed to initialize driver.");    if (getmaxcolor() + 1 < ColorMapSize) {	sprintf(Str, "GIF Image color map (%d) is too big for device (%d)./n",					      ColorMapSize, getmaxcolor() + 1);	closegraph();	GIF_EXIT(Str);    }
开发者ID:daemqn,项目名称:Atari_ST_Sources,代码行数:67,


示例19: main

int main(int argc, char **argv) {   //   // local vars   //   GifFileType *GIFfile;   GifRecordType GIFtype;   GifByteType *GIFextension;   GifPixelType *GIFline;   uint32_t w[8],**lower_array,**upper_array;   int x,y,z,i,j,k,n,p,imin,imax;   int image_width,image_height,image_count,color_resolution,GIFcode,ret;   float threshold,voxel_size;   char comment[256],rules[255][20];   struct fab_vars v;   init_vars(&v);   //   // command line args   //   if (!((argc == 3) || (argc == 4) || (argc == 5) || (argc == 6))) {      printf("command line: gif_stl in.gif out.stl [threshold [size [points [angle]]]]/n");      printf("   in.gif = input GIF section file/n");      printf("   out.stl = output STL file/n");      printf("   threshold: surface intensity threshold (0 = min, 1 = max, default 0.5))/n");      printf("   size = voxel size (mm, default from file))/n");      printf("   points = points to interpolate per point (default 0)/n");      printf("   to be implemented: angle = minimum relative face angle to decimate vertices (default 0)/n");      exit(-1);      }   p = 0;   threshold = 0.5;   voxel_size = -1;   image_width = -1;   image_height = -1;   image_count = -1;   if (argc >= 4)      sscanf(argv[3],"%f",&threshold);   if (argc >= 5)      sscanf(argv[4],"%f",&voxel_size);   if (argc >= 6)      sscanf(argv[5],"%d",&p);   //   // initialize the rule table   //   init_rules(rules);   //   // scan the file    //   printf("read %s/n",argv[1]);   color_resolution = -1;#if GIFLIB_MAJOR >= 5   GIFfile = DGifOpenFileName(argv[1], NULL);#else   GIFfile = DGifOpenFileName(argv[1]);#endif   if (GIFfile == NULL) {      printf("gif_stl: oops -- can not open %s/n",argv[1]);      exit(-1);      }   GIFline = malloc(MAX_LINE*sizeof(GifPixelType));   imin = 256;   imax = 0;   do {      DGifGetRecordType(GIFfile,&GIFtype);      switch (GIFtype) {         case IMAGE_DESC_RECORD_TYPE:            DGifGetImageDesc(GIFfile);            image_width = GIFfile->SWidth;            image_height = GIFfile->SHeight;            image_count = GIFfile->ImageCount;            color_resolution = GIFfile->SColorResolution;            for (y = 0; y < GIFfile->SHeight; ++y) {               ret = DGifGetLine(GIFfile,GIFline,GIFfile->SWidth);               if (ret != GIF_OK) {                  printf("gif_stl: oops -- error reading line/n");                  exit(-1);                  }               for (x = 0; x < GIFfile->SWidth; ++x) {                  if (GIFline[x] < imin) imin = GIFline[x];                  if (GIFline[x] > imax) imax = GIFline[x];                  }               }            break;         case EXTENSION_RECORD_TYPE:            DGifGetExtension(GIFfile,&GIFcode,&GIFextension);            if (GIFcode == COMMENT_EXT_FUNC_CODE) {               n = GIFextension[0];               for (i = 1; i <= n; ++i)                  comment[i-1] = GIFextension[i];               comment[n] = 0;               if (voxel_size == -1)                  sscanf(comment,"mm per pixel: %f;",&voxel_size);               }            while (GIFextension != NULL)               DGifGetExtensionNext(GIFfile,&GIFextension);            break;         case SCREEN_DESC_RECORD_TYPE:            DGifGetScreenDesc(GIFfile);            break;         case TERMINATE_RECORD_TYPE:            break;//.........这里部分代码省略.........
开发者ID:TheBeachLab,项目名称:kokoretro,代码行数:101,


示例20: DGifOpenFileName

//.........这里部分代码省略.........				}			}			buffer = malloc(width * sizeof(GifColorType));			if (!buffer) {				RErrorCode = RERR_NOMEMORY;				goto bye;			}			image = RCreateImage(width, height, False);			if (!image) {				goto bye;			}			if (gif->Image.Interlace) {				int l;				int pelsPerLine;				if (RRGBAFormat == image->format)					pelsPerLine = width * 4;				else					pelsPerLine = width * 3;				for (j = 0; j < 4; j++) {					for (k = InterlacedOffset[j]; k < height; k += InterlacedJumps[j]) {						if (DGifGetLine(gif, buffer, width) == GIF_ERROR) {							goto giferr;						}						cptr = image->data + (k * pelsPerLine);						for (l = 0; l < width; l++) {							int pixel = buffer[l];							*cptr++ = rmap[pixel];							*cptr++ = gmap[pixel];							*cptr++ = bmap[pixel];						}					}				}			} else {				cptr = image->data;				for (j = 0; j < height; j++) {					if (DGifGetLine(gif, buffer, width) == GIF_ERROR) {						goto giferr;					}					for (k = 0; k < width; k++) {						int pixel = buffer[k];						*cptr++ = rmap[pixel];						*cptr++ = gmap[pixel];						*cptr++ = bmap[pixel];						if (RRGBAFormat == image->format)							cptr++;					}				}			}			break;		case EXTENSION_RECORD_TYPE:			/* skip all extension blocks */			if (DGifGetExtension(gif, &extCode, &extension) == GIF_ERROR) {				goto giferr;			}			while (extension) {				if (DGifGetExtensionNext(gif, &extension) == GIF_ERROR) {					goto giferr;				}			}			break;		default:			break;		}	} while (recType != TERMINATE_RECORD_TYPE && i <= index);	/* yuck! */	goto did_not_get_any_errors; giferr:	switch (GifLastError()) {	case D_GIF_ERR_OPEN_FAILED:		RErrorCode = RERR_OPEN;		break;	case D_GIF_ERR_READ_FAILED:		RErrorCode = RERR_READ;		break;	default:		RErrorCode = RERR_BADIMAGEFILE;		break;	} bye:	if (image)		RReleaseImage(image);	image = NULL; did_not_get_any_errors:	if (buffer)		free(buffer);	if (gif)		DGifCloseFile(gif);	return image;}
开发者ID:crmafra,项目名称:wmaker,代码行数:101,


示例21: img_load_gif

bool img_load_gif(img_t *img, const fileinfo_t *file){	GifFileType *gif;	GifRowType *rows = NULL;	GifRecordType rec;	ColorMapObject *cmap;	DATA32 bgpixel, *data, *ptr;	DATA32 *prev_frame = NULL;	Imlib_Image im;	int i, j, bg, r, g, b;	int x, y, w, h, sw, sh;	int px, py, pw, ph;	int intoffset[] = { 0, 4, 2, 1 };	int intjump[] = { 8, 8, 4, 2 };	int transp = -1;	unsigned int disposal = 0, prev_disposal = 0;	unsigned int delay = 0;	bool err = false;	if (img->multi.cap == 0) {		img->multi.cap = 8;		img->multi.frames = (img_frame_t*)		                    s_malloc(sizeof(img_frame_t) * img->multi.cap);	}	img->multi.cnt = img->multi.sel = 0;	img->multi.length = 0;#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5	gif = DGifOpenFileName(file->path, NULL);#else	gif = DGifOpenFileName(file->path);#endif	if (gif == NULL) {		warn("could not open gif file: %s", file->name);		return false;	}	bg = gif->SBackGroundColor;	sw = gif->SWidth;	sh = gif->SHeight;	px = py = pw = ph = 0;	do {		if (DGifGetRecordType(gif, &rec) == GIF_ERROR) {			err = true;			break;		}		if (rec == EXTENSION_RECORD_TYPE) {			int ext_code;			GifByteType *ext = NULL;			DGifGetExtension(gif, &ext_code, &ext);			while (ext) {				if (ext_code == GRAPHICS_EXT_FUNC_CODE) {					if (ext[1] & 1)						transp = (int) ext[4];					else						transp = -1;					delay = 10 * ((unsigned int) ext[3] << 8 | (unsigned int) ext[2]);					disposal = (unsigned int) ext[1] >> 2 & 0x7;				}				ext = NULL;				DGifGetExtensionNext(gif, &ext);			}		} else if (rec == IMAGE_DESC_RECORD_TYPE) {			if (DGifGetImageDesc(gif) == GIF_ERROR) {				err = true;				break;			}			x = gif->Image.Left;			y = gif->Image.Top;			w = gif->Image.Width;			h = gif->Image.Height;			rows = (GifRowType*) s_malloc(h * sizeof(GifRowType));			for (i = 0; i < h; i++)				rows[i] = (GifRowType) s_malloc(w * sizeof(GifPixelType));			if (gif->Image.Interlace) {				for (i = 0; i < 4; i++) {					for (j = intoffset[i]; j < h; j += intjump[i])						DGifGetLine(gif, rows[j], w);				}			} else {				for (i = 0; i < h; i++)					DGifGetLine(gif, rows[i], w);			}			ptr = data = (DATA32*) s_malloc(sizeof(DATA32) * sw * sh);			cmap = gif->Image.ColorMap ? gif->Image.ColorMap : gif->SColorMap;			r = cmap->Colors[bg].Red;			g = cmap->Colors[bg].Green;			b = cmap->Colors[bg].Blue;			bgpixel = 0x00ffffff & (r << 16 | g << 8 | b);			for (i = 0; i < sh; i++) {				for (j = 0; j < sw; j++) {					if (i < y || i >= y + h || j < x || j >= x + w ||					    rows[i-y][j-x] == transp)					{						if (prev_frame != NULL && (prev_disposal != 2 ||//.........这里部分代码省略.........
开发者ID:JulioJu,项目名称:sxiv,代码行数:101,


示例22: loader_gif

//.........这里部分代码省略.........	    {	      rows[i] = malloc(*w * sizeof(GifPixelType));	      if (!rows[i])		{		  DGifCloseFile(gif);		  for (i = 0; i < *h; i++)		    if (rows[i])		      free(rows[i]);		  free(rows);		  free(data);		  return NULL;		}	    }	  if (gif->Image.Interlace)	    {	      for (i = 0; i < 4; i++)		{		  for (j = intoffset[i]; j < *h; j += intjump[i])		    DGifGetLine(gif, rows[j], *w);		}	    }	  else	    {	      for (i = 0; i < *h; i++)		DGifGetLine(gif, rows[i], *w);	    }	  done = 1;	}      else if (rec == EXTENSION_RECORD_TYPE)	{	  int                 ext_code;	  GifByteType        *ext;	  ext = NULL;	  DGifGetExtension(gif, &ext_code, &ext);	  while (ext)	    {	      if ((ext_code == 0xf9) && (ext[1] & 1) && (transp < 0))		{		  istransp = 1;		  transp = (int)ext[4];		}	      ext = NULL;	      DGifGetExtensionNext(gif, &ext);	    }	}    }  while (rec != TERMINATE_RECORD_TYPE);  bg = gif->SBackGroundColor;  cmap = (gif->Image.ColorMap ? gif->Image.ColorMap : gif->SColorMap);  csize = cmap->ColorCount;  ptr = data;  if (!istransp)    {      for (i = 0; i < *h; i++)	{	  for (j = 0; j < *w; j++)	    {	      r = cmap->Colors[rows[i][j]].Red;	      g = cmap->Colors[rows[i][j]].Green;	      b = cmap->Colors[rows[i][j]].Blue;	      *ptr++ = r;	      *ptr++ = g;	      *ptr++ = b;	    }	}    }  else    {      for (i = 0; i < *h; i++)	{	  for (j = 0; j < *w; j++)	    {	      if (rows[i][j] == transp)		{		  *ptr++ = 255;		  *ptr++ = 0;		  *ptr++ = 255;		}	      else		{		  r = cmap->Colors[rows[i][j]].Red;		  g = cmap->Colors[rows[i][j]].Green;		  b = cmap->Colors[rows[i][j]].Blue;		  if (r == 255 && g == 0 && b == 255)		    r = 254;		  *ptr++ = r;		  *ptr++ = g;		  *ptr++ = b;		}	    }	}    }  DGifCloseFile(gif);  for (i = 0; i < *h; i++)    free(rows[i]);  free(rows);  *t = istransp;  return data;}
开发者ID:dbentall,项目名称:Multiprocessing,代码行数:101,


示例23: DGifOpenFileName

/****************************************************************************** This routine reads an entire GIF into core, hanging all its state info off the GifFileType pointer.  Call DGifOpenFileName() or DGifOpenFileHandle() first to initialize I/O.  Its inverse is EGifSpew().*******************************************************************************/intDGifSlurp(GifFileType *GifFile){    size_t ImageSize;    GifRecordType RecordType;    SavedImage *sp;    GifByteType *ExtData;    int ExtFunction;    GifFile->ExtensionBlocks = NULL;    GifFile->ExtensionBlockCount = 0;    do {        if (DGifGetRecordType(GifFile, &RecordType) == GIF_ERROR)            return (GIF_ERROR);        switch (RecordType) {          case IMAGE_DESC_RECORD_TYPE:              if (DGifGetImageDesc(GifFile) == GIF_ERROR)                  return (GIF_ERROR);              sp = &GifFile->SavedImages[GifFile->ImageCount - 1];              /* Allocate memory for the image */              if (sp->ImageDesc.Width < 0 && sp->ImageDesc.Height < 0 &&                      sp->ImageDesc.Width > (INT_MAX / sp->ImageDesc.Height)) {                  return GIF_ERROR;              }              ImageSize = sp->ImageDesc.Width * sp->ImageDesc.Height;              if (ImageSize > (SIZE_MAX / sizeof(GifPixelType))) {                  return GIF_ERROR;              }              sp->RasterBits = (unsigned char *)malloc(ImageSize *                      sizeof(GifPixelType));              if (sp->RasterBits == NULL) {                  return GIF_ERROR;              }	      if (sp->ImageDesc.Interlace) {		  int i, j;		   /* 		    * The way an interlaced image should be read - 		    * offsets and jumps...		    */		  int InterlacedOffset[] = { 0, 4, 2, 1 };		  int InterlacedJumps[] = { 8, 8, 4, 2 };		  /* Need to perform 4 passes on the image */		  for (i = 0; i < 4; i++)		      for (j = InterlacedOffset[i]; 			   j < sp->ImageDesc.Height;			   j += InterlacedJumps[i]) {			  if (DGifGetLine(GifFile, 					  sp->RasterBits+j*sp->ImageDesc.Width, 					  sp->ImageDesc.Width) == GIF_ERROR)			      return GIF_ERROR;		      }	      }	      else {		  if (DGifGetLine(GifFile,sp->RasterBits,ImageSize)==GIF_ERROR)		      return (GIF_ERROR);	      }              if (GifFile->ExtensionBlocks) {                  sp->ExtensionBlocks = GifFile->ExtensionBlocks;                  sp->ExtensionBlockCount = GifFile->ExtensionBlockCount;                  GifFile->ExtensionBlocks = NULL;                  GifFile->ExtensionBlockCount = 0;              }              break;          case EXTENSION_RECORD_TYPE:              if (DGifGetExtension(GifFile,&ExtFunction,&ExtData) == GIF_ERROR)                  return (GIF_ERROR);	      /* Create an extension block with our data */	      if (GifAddExtensionBlock(&GifFile->ExtensionBlockCount,				       &GifFile->ExtensionBlocks, 				       ExtFunction, ExtData[0], &ExtData[1])		  == GIF_ERROR)		  return (GIF_ERROR);              while (ExtData != NULL) {                  if (DGifGetExtensionNext(GifFile, &ExtData) == GIF_ERROR)                      return (GIF_ERROR);                  /* Continue the extension block */		  if (ExtData != NULL)		      if (GifAddExtensionBlock(&GifFile->ExtensionBlockCount,					       &GifFile->ExtensionBlocks,					       CONTINUE_EXT_FUNC_CODE, 					       ExtData[0], &ExtData[1]) == GIF_ERROR)                      return (GIF_ERROR);              }              break;          case TERMINATE_RECORD_TYPE://.........这里部分代码省略.........
开发者ID:9miao,项目名称:CrossApp,代码行数:101,


示例24: main

//.........这里部分代码省略.........	QuitGifError(GifFileIn, GifFileOut);    /* Scan the content of the GIF file and load the image(s) in: */    do {	if (DGifGetRecordType(GifFileIn, &RecordType) == GIF_ERROR)	    QuitGifError(GifFileIn, GifFileOut);	switch (RecordType) {	    case IMAGE_DESC_RECORD_TYPE:		if (DGifGetImageDesc(GifFileIn) == GIF_ERROR)		    QuitGifError(GifFileIn, GifFileOut);		/* Put the image descriptor to out file: */		l = (int) (GifFileIn->Image.Left * XScale + 0.5);		w = (int) (GifFileIn->Image.Width * XScale + 0.5);		t = (int) (GifFileIn->Image.Top * YScale + 0.5);		h = (int) (GifFileIn->Image.Height * YScale + 0.5);		if (l < 0) l = 0;		if (t < 0) t = 0;		if (l + w > XSize) w = XSize - l;		if (t + h > YSize) h = YSize - t;		if (EGifPutImageDesc(GifFileOut, l, t, w, h,		    GifFileIn->Image.Interlace,		    GifFileIn->Image.ColorMap) == GIF_ERROR)		    QuitGifError(GifFileIn, GifFileOut);		if (GifFileIn->Image.Interlace) {		    GIF_EXIT("Cannt resize interlaced images - use GifInter first.");		}		else {		    GifQprintf("/n%s: Image %d at (%d, %d) [%dx%d]:     ",			PROGRAM_NAME, ++ImageNum,			GifFileOut->Image.Left, GifFileOut->Image.Top,			GifFileOut->Image.Width, GifFileOut->Image.Height);		    for (i = GifFileIn->Image.Height, y = 0.0, last_iy = -1;			 i-- > 0;			 y += YScale) {			if (DGifGetLine(GifFileIn, LineIn,					GifFileIn->Image.Width) == GIF_ERROR)			    QuitGifError(GifFileIn, GifFileOut);			iy = (int) y;			if (last_iy < iy && last_iy < YSize) {			    ResizeLine(LineIn, LineOut,				       GifFileIn->Image.Width, GifFileOut->Image.Width);			    for (;				 last_iy < iy && last_iy < GifFileOut->Image.Height - 1;				 last_iy++) {				GifQprintf("/b/b/b/b%-4d", last_iy + 1);				if (EGifPutLine(GifFileOut, LineOut,						GifFileOut->Image.Width) ==								    GIF_ERROR)				    QuitGifError(GifFileIn, GifFileOut);			    }			}		    }		    /* If scale is not dividable - dump last lines: */		    while (++last_iy < GifFileOut->Image.Height) {			GifQprintf("/b/b/b/b%-4d", last_iy);			if (EGifPutLine(GifFileOut, LineOut,					GifFileOut->Image.Width) == GIF_ERROR)			    QuitGifError(GifFileIn, GifFileOut);		    }		}		break;	    case EXTENSION_RECORD_TYPE:		/* Skip any extension blocks in file: */		if (DGifGetExtension(GifFileIn, &ExtCode, &Extension) == GIF_ERROR)		    QuitGifError(GifFileIn, GifFileOut);		if (EGifPutExtension(GifFileOut, ExtCode, Extension[0],							Extension) == GIF_ERROR)		    QuitGifError(GifFileIn, GifFileOut);		/* No support to more than one extension blocks, so discard: */		while (Extension != NULL) {		    if (DGifGetExtensionNext(GifFileIn, &Extension) == GIF_ERROR)			QuitGifError(GifFileIn, GifFileOut);		}		break;	    case TERMINATE_RECORD_TYPE:		break;	    default:		    /* Should be traps by DGifGetRecordType. */		break;	}    }    while (RecordType != TERMINATE_RECORD_TYPE);    if (DGifCloseFile(GifFileIn) == GIF_ERROR)	QuitGifError(GifFileIn, GifFileOut);    if (EGifCloseFile(GifFileOut) == GIF_ERROR)	QuitGifError(GifFileIn, GifFileOut);    free(LineOut);    free(LineIn);    return 0;}
开发者ID:BOTCrusher,项目名称:sagetv,代码行数:101,


示例25: main

/****************************************************************************** Main sequence******************************************************************************/int main(int argc, char **argv){    GifFileType *GifFileIn = NULL, *GifFileOut = NULL;    GifRecordType RecordType;    int CodeSize, ExtCode, ErrorCode;    GifByteType *CodeBlock, *Extension;    /*     * Command-line processing goes here.     */    /* Use stdin as input (note this also read screen descriptor in: */    if ((GifFileIn = DGifOpenFileHandle(0, &ErrorCode)) == NULL) {	PrintGifError(ErrorCode);	exit(EXIT_FAILURE);    }    /* Use the stdout as output: */    if ((GifFileOut = EGifOpenFileHandle(1, &ErrorCode)) == NULL) {	PrintGifError(ErrorCode);	exit(EXIT_FAILURE);    }    /* And dump out its screen information: */    if (EGifPutScreenDesc(GifFileOut,	GifFileIn->SWidth, GifFileIn->SHeight,	GifFileIn->SColorResolution, GifFileIn->SBackGroundColor,	GifFileIn->SColorMap) == GIF_ERROR)	QuitGifError(GifFileIn, GifFileOut);    /* Scan the content of the input GIF file and load the image(s) in: */    do {	if (DGifGetRecordType(GifFileIn, &RecordType) == GIF_ERROR)	    QuitGifError(GifFileIn, GifFileOut);	switch (RecordType) {	    case IMAGE_DESC_RECORD_TYPE:		if (DGifGetImageDesc(GifFileIn) == GIF_ERROR)		    QuitGifError(GifFileIn, GifFileOut);		/* Put image descriptor to out file: */		if (EGifPutImageDesc(GifFileOut,		    GifFileIn->Image.Left, GifFileIn->Image.Top,		    GifFileIn->Image.Width, GifFileIn->Image.Height,		    GifFileIn->Image.Interlace,		    GifFileIn->Image.ColorMap) == GIF_ERROR)		    QuitGifError(GifFileIn, GifFileOut);		/* Now read image itself in decoded form as we dont really   */		/* care what we have there, and this is much faster.	     */		if (DGifGetCode(GifFileIn, &CodeSize, &CodeBlock) == GIF_ERROR ||		    EGifPutCode(GifFileOut, CodeSize, CodeBlock) == GIF_ERROR)		    QuitGifError(GifFileIn, GifFileOut);		while (CodeBlock != NULL) {		    if (DGifGetCodeNext(GifFileIn, &CodeBlock) == GIF_ERROR ||			EGifPutCodeNext(GifFileOut, CodeBlock) == GIF_ERROR)		    QuitGifError(GifFileIn, GifFileOut);		}		break;	    case EXTENSION_RECORD_TYPE:		/* pass through extension records */		if (DGifGetExtension(GifFileIn, &ExtCode, &Extension) == GIF_ERROR)		    QuitGifError(GifFileIn, GifFileOut);		if (EGifPutExtensionLeader(GifFileOut, ExtCode) == GIF_ERROR)		    QuitGifError(GifFileIn, GifFileOut);		if (EGifPutExtensionBlock(GifFileOut, 					  Extension[0],					  Extension + 1) == GIF_ERROR)		    QuitGifError(GifFileIn, GifFileOut);		while (Extension != NULL) {		    if (DGifGetExtensionNext(GifFileIn, &Extension)==GIF_ERROR)			QuitGifError(GifFileIn, GifFileOut);		    if (Extension != NULL)			if (EGifPutExtensionBlock(GifFileOut, 						  Extension[0],						  Extension + 1) == GIF_ERROR)			    QuitGifError(GifFileIn, GifFileOut);		}		if (EGifPutExtensionTrailer(GifFileOut) == GIF_ERROR)		    QuitGifError(GifFileIn, GifFileOut);		break;	    case TERMINATE_RECORD_TYPE:		break;	    default:	     /* Should be trapped by DGifGetRecordType */		break;	}    }    while (RecordType != TERMINATE_RECORD_TYPE);    if (DGifCloseFile(GifFileIn, &ErrorCode) == GIF_ERROR)    {	PrintGifError(ErrorCode);	if (GifFileIn != NULL) {	    EGifCloseFile(GifFileIn, NULL);	}	exit(EXIT_FAILURE);    }    if (EGifCloseFile(GifFileOut, &ErrorCode) == GIF_ERROR)//.........这里部分代码省略.........
开发者ID:FyhSky,项目名称:gifdemo,代码行数:101,


示例26: img_load_gif

bool img_load_gif(img_t *img, const fileinfo_t *file){	GifFileType *gif;	GifRowType *rows = NULL;	GifRecordType rec;	ColorMapObject *cmap;	DATA32 bgpixel, *data, *ptr;	DATA32 *prev_frame = NULL;	Imlib_Image im;	int i, j, bg, r, g, b;	int x, y, w, h, sw, sh;	int px, py, pw, ph;	int intoffset[] = { 0, 4, 2, 1 };	int intjump[] = { 8, 8, 4, 2 };	int transp = -1;	unsigned int disposal = 0, prev_disposal = 0;	unsigned int delay = 0;	bool err = false;	if (img->multi.cap == 0) {		img->multi.cap = 8;		img->multi.frames = (img_frame_t*)		                    s_malloc(sizeof(img_frame_t) * img->multi.cap);	}	img->multi.cnt = img->multi.sel = 0;	img->multi.length = img->multi.repeat = 0;#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5	gif = DGifOpenFileName(file->path, NULL);#else	gif = DGifOpenFileName(file->path);#endif	if (gif == NULL) {		warn("could not open gif file: %s", file->name);		return false;	}	bg = gif->SBackGroundColor;	sw = gif->SWidth;	sh = gif->SHeight;	px = py = pw = ph = 0;	do {		if (DGifGetRecordType(gif, &rec) == GIF_ERROR) {			err = true;			break;		}		if (rec == EXTENSION_RECORD_TYPE) {			int ext_code;			GifByteType *ext = NULL;			DGifGetExtension(gif, &ext_code, &ext);			while (ext) {				if (ext_code == GRAPHICS_EXT_FUNC_CODE) {					if (ext[1] & 1)						transp = (int) ext[4];					else						transp = -1;					delay = 10 * ((unsigned int) ext[3] << 8 | (unsigned int) ext[2]);					if (delay)						delay = MAX(delay, MIN_GIF_DELAY);					disposal = (unsigned int) ext[1] >> 2 & 0x7;				} else if (ext_code == APPLICATION_EXT_FUNC_CODE) {					if (ext[0] == 11 && memcmp(ext+1, "NETSCAPE2.0", 11) == 0) {						DGifGetExtensionNext(gif, &ext);						if (ext && ext[0] == 3 && ext[1] == 1)							img->multi.repeat = ((int) ext[3] << 8 | (int) ext[2]) - 1;					}				}				ext = NULL;				DGifGetExtensionNext(gif, &ext);			}		} else if (rec == IMAGE_DESC_RECORD_TYPE) {
开发者ID:kkb7401,项目名称:sxiv,代码行数:74,


示例27: main

/******************************************************************************* Interpret the command line and scan the given GIF file.		      *******************************************************************************/void main(int argc, char **argv){    int	Error, NumFiles, ExtCode;    GifRecordType RecordType;    GifByteType *Extension;    char **FileName = NULL;    GifRowType *ImageBuffer;    GifFileType *GifFileIn = NULL, *GifFileOut = NULL;    if ((Error = GAGetArgs(argc, argv, CtrlStr, &GifQuitePrint,		&InterlacedFlag, &SequencialFlag, &HelpFlag,		&NumFiles, &FileName)) != FALSE ||		(NumFiles > 1 && !HelpFlag)) {	if (Error)	    GAPrintErrMsg(Error);	else if (NumFiles > 1)	    GIF_MESSAGE("Error in command line parsing - one GIF file please.");	GAPrintHowTo(CtrlStr);	exit(1);    }    if (HelpFlag) {	fprintf(stderr, VersionStr);	GAPrintHowTo(CtrlStr);	exit(0);    }    if (NumFiles == 1) {	if ((GifFileIn = DGifOpenFileName(*FileName)) == NULL)	    QuitGifError(GifFileIn, GifFileOut);    }    else {	/* Use the stdin instead: */	if ((GifFileIn = DGifOpenFileHandle(0)) == NULL)	    QuitGifError(GifFileIn, GifFileOut);    }    /* Open stdout for the output file: */    if ((GifFileOut = EGifOpenFileHandle(1)) == NULL)	QuitGifError(GifFileIn, GifFileOut);    /* And dump out exactly same screen information: */    if (EGifPutScreenDesc(GifFileOut,	GifFileIn -> SWidth, GifFileIn -> SHeight,	GifFileIn -> SColorResolution, GifFileIn -> SBackGroundColor,	GifFileIn -> SBitsPerPixel, GifFileIn -> SColorMap) == GIF_ERROR)	QuitGifError(GifFileIn, GifFileOut);    /* Scan the content of the GIF file and load the image(s) in: */    do {	if (DGifGetRecordType(GifFileIn, &RecordType) == GIF_ERROR)	    QuitGifError(GifFileIn, GifFileOut);	switch (RecordType) {	    case IMAGE_DESC_RECORD_TYPE:		if (DGifGetImageDesc(GifFileIn) == GIF_ERROR)		    QuitGifError(GifFileIn, GifFileOut);		/* Put the image descriptor to out file: */		if (EGifPutImageDesc(GifFileOut,		    GifFileIn -> ILeft, GifFileIn -> ITop,		    GifFileIn -> IWidth, GifFileIn -> IHeight,		    InterlacedFlag, GifFileIn -> IBitsPerPixel,		    GifFileIn -> IColorMap) == GIF_ERROR)		    QuitGifError(GifFileIn, GifFileOut);		/* Load the image (either Interlaced or not), and dump it as */		/* defined in GifFileOut -> IInterlaced.		     */		if (LoadImage(GifFileIn, &ImageBuffer) == GIF_ERROR)		    QuitGifError(GifFileIn, GifFileOut);		if (DumpImage(GifFileOut, ImageBuffer) == GIF_ERROR)		    QuitGifError(GifFileIn, GifFileOut);		break;	    case EXTENSION_RECORD_TYPE:		/* Skip any extension blocks in file: */		if (DGifGetExtension(GifFileIn, &ExtCode, &Extension) == GIF_ERROR)		    QuitGifError(GifFileIn, GifFileOut);		if (EGifPutExtension(GifFileOut, ExtCode, Extension[0],							Extension) == GIF_ERROR)		    QuitGifError(GifFileIn, GifFileOut);		/* No support to more than one extension blocks, so discard: */		while (Extension != NULL) {		    if (DGifGetExtensionNext(GifFileIn, &Extension) == GIF_ERROR)			QuitGifError(GifFileIn, GifFileOut);		}		break;	    case TERMINATE_RECORD_TYPE:		break;	    default:		    /* Should be traps by DGifGetRecordType. */		break;	}    }    while (RecordType != TERMINATE_RECORD_TYPE);    if (DGifCloseFile(GifFileIn) == GIF_ERROR)	QuitGifError(GifFileIn, GifFileOut);//.........这里部分代码省略.........
开发者ID:daemqn,项目名称:Atari_ST_Sources,代码行数:101,



注:本文中的DGifGetExtensionNext函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ DGifGetImageDesc函数代码示例
C++ DGifGetExtension函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。