Lines Matching defs:GifFile
35 static int DGifGetWord(GifFileType *GifFile, GifWord *Word);
36 static int DGifSetupDecompress(GifFileType *GifFile);
37 static int DGifDecompressLine(GifFileType *GifFile, GifPixelType *Line,
40 static int DGifDecompressInput(GifFileType *GifFile, int *Code);
41 static int DGifBufferedInput(GifFileType *GifFile, GifByteType *Buf,
53 GifFileType *GifFile;
61 GifFile = DGifOpenFileHandle(FileHandle, Error);
62 return GifFile;
74 GifFileType *GifFile;
78 GifFile = (GifFileType *)malloc(sizeof(GifFileType));
79 if (GifFile == NULL) {
86 /*@i1@*/memset(GifFile, '\0', sizeof(GifFileType));
89 GifFile->SavedImages = NULL;
90 GifFile->SColorMap = NULL;
97 free((char *)GifFile);
110 GifFile->Private = (void *)Private;
115 GifFile->UserData = NULL; /* TVT */
120 if (READ(GifFile, (unsigned char *)Buf, GIF_STAMP_LEN) != GIF_STAMP_LEN) {
125 free((char *)GifFile);
136 free((char *)GifFile);
140 if (DGifGetScreenDesc(GifFile) == GIF_ERROR) {
143 free((char *)GifFile);
147 GifFile->Error = 0;
152 return GifFile;
162 GifFileType *GifFile;
165 GifFile = (GifFileType *)malloc(sizeof(GifFileType));
166 if (GifFile == NULL) {
172 memset(GifFile, '\0', sizeof(GifFileType));
175 GifFile->SavedImages = NULL;
176 GifFile->SColorMap = NULL;
182 free((char *)GifFile);
187 GifFile->Private = (void *)Private;
193 GifFile->UserData = userData; /* TVT */
197 if (READ(GifFile, (unsigned char *)Buf, GIF_STAMP_LEN) != GIF_STAMP_LEN) {
201 free((char *)GifFile);
211 free((char *)GifFile);
215 if (DGifGetScreenDesc(GifFile) == GIF_ERROR) {
217 free((char *)GifFile);
223 GifFile->Error = 0;
228 return GifFile;
236 DGifGetScreenDesc(GifFileType *GifFile)
241 GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
245 GifFile->Error = D_GIF_ERR_NOT_READABLE;
250 if (DGifGetWord(GifFile, &GifFile->SWidth) == GIF_ERROR ||
251 DGifGetWord(GifFile, &GifFile->SHeight) == GIF_ERROR)
254 if (READ(GifFile, Buf, 3) != 3) {
255 GifFile->Error = D_GIF_ERR_READ_FAILED;
256 GifFreeMapObject(GifFile->SColorMap);
257 GifFile->SColorMap = NULL;
260 GifFile->SColorResolution = (((Buf[0] & 0x70) + 1) >> 4) + 1;
263 GifFile->SBackGroundColor = Buf[1];
264 GifFile->AspectByte = Buf[2];
268 GifFile->SColorMap = GifMakeMapObject(1 << BitsPerPixel, NULL);
269 if (GifFile->SColorMap == NULL) {
270 GifFile->Error = D_GIF_ERR_NOT_ENOUGH_MEM;
275 GifFile->SColorMap->SortFlag = SortFlag;
276 for (i = 0; i < GifFile->SColorMap->ColorCount; i++) {
278 if (READ(GifFile, Buf, 3) != 3) {
279 GifFreeMapObject(GifFile->SColorMap);
280 GifFile->SColorMap = NULL;
281 GifFile->Error = D_GIF_ERR_READ_FAILED;
284 GifFile->SColorMap->Colors[i].Red = Buf[0];
285 GifFile->SColorMap->Colors[i].Green = Buf[1];
286 GifFile->SColorMap->Colors[i].Blue = Buf[2];
289 GifFile->SColorMap = NULL;
299 DGifGetRecordType(GifFileType *GifFile, GifRecordType* Type)
302 GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
306 GifFile->Error = D_GIF_ERR_NOT_READABLE;
311 if (READ(GifFile, &Buf, 1) != 1) {
312 GifFile->Error = D_GIF_ERR_READ_FAILED;
328 GifFile->Error = D_GIF_ERR_WRONG_RECORD;
340 DGifGetImageDesc(GifFileType *GifFile)
344 GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
349 GifFile->Error = D_GIF_ERR_NOT_READABLE;
353 if (DGifGetWord(GifFile, &GifFile->Image.Left) == GIF_ERROR ||
354 DGifGetWord(GifFile, &GifFile->Image.Top) == GIF_ERROR ||
355 DGifGetWord(GifFile, &GifFile->Image.Width) == GIF_ERROR ||
356 DGifGetWord(GifFile, &GifFile->Image.Height) == GIF_ERROR)
358 if (READ(GifFile, Buf, 1) != 1) {
359 GifFile->Error = D_GIF_ERR_READ_FAILED;
360 GifFreeMapObject(GifFile->Image.ColorMap);
361 GifFile->Image.ColorMap = NULL;
365 GifFile->Image.Interlace = (Buf[0] & 0x40) ? true : false;
368 if (GifFile->Image.ColorMap) {
369 GifFreeMapObject(GifFile->Image.ColorMap);
370 GifFile->Image.ColorMap = NULL;
376 GifFile->Image.ColorMap = GifMakeMapObject(1 << BitsPerPixel, NULL);
377 if (GifFile->Image.ColorMap == NULL) {
378 GifFile->Error = D_GIF_ERR_NOT_ENOUGH_MEM;
383 for (i = 0; i < GifFile->Image.ColorMap->ColorCount; i++) {
385 if (READ(GifFile, Buf, 3) != 3) {
386 GifFreeMapObject(GifFile->Image.ColorMap);
387 GifFile->Error = D_GIF_ERR_READ_FAILED;
388 GifFile->Image.ColorMap = NULL;
391 GifFile->Image.ColorMap->Colors[i].Red = Buf[0];
392 GifFile->Image.ColorMap->Colors[i].Green = Buf[1];
393 GifFile->Image.ColorMap->Colors[i].Blue = Buf[2];
397 if (GifFile->SavedImages) {
399 (SavedImage *)reallocarray(GifFile->SavedImages,
400 (GifFile->ImageCount + 1), sizeof(SavedImage));
402 GifFile->Error = D_GIF_ERR_NOT_ENOUGH_MEM;
405 GifFile->SavedImages = new_saved_images;
407 if ((GifFile->SavedImages =
409 GifFile->Error = D_GIF_ERR_NOT_ENOUGH_MEM;
414 sp = &GifFile->SavedImages[GifFile->ImageCount];
415 memcpy(&sp->ImageDesc, &GifFile->Image, sizeof(GifImageDesc));
416 if (GifFile->Image.ColorMap != NULL) {
418 GifFile->Image.ColorMap->ColorCount,
419 GifFile->Image.ColorMap->Colors);
421 GifFile->Error = D_GIF_ERR_NOT_ENOUGH_MEM;
429 GifFile->ImageCount++;
431 Private->PixelCount = (long)GifFile->Image.Width *
432 (long)GifFile->Image.Height;
435 return DGifSetupDecompress(GifFile);
442 DGifGetLine(GifFileType *GifFile, GifPixelType *Line, int LineLen)
445 GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;
449 GifFile->Error = D_GIF_ERR_NOT_READABLE;
454 LineLen = GifFile->Image.Width;
457 GifFile->Error = D_GIF_ERR_DATA_TOO_BIG;
461 if (DGifDecompressLine(GifFile, Line, LineLen) == GIF_OK) {
469 if (DGifGetCodeNext(GifFile, &Dummy) == GIF_ERROR)
482 DGifGetPixel(GifFileType *GifFile, GifPixelType Pixel)
485 GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;
489 GifFile->Error = D_GIF_ERR_NOT_READABLE;
494 GifFile->Error = D_GIF_ERR_DATA_TOO_BIG;
498 if (DGifDecompressLine(GifFile, &Pixel, 1) == GIF_OK) {
506 if (DGifGetCodeNext(GifFile, &Dummy) == GIF_ERROR)
523 DGifGetExtension(GifFileType *GifFile, int *ExtCode, GifByteType **Extension)
526 GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
530 GifFile->Error = D_GIF_ERR_NOT_READABLE;
535 if (READ(GifFile, &Buf, 1) != 1) {
536 GifFile->Error = D_GIF_ERR_READ_FAILED;
541 return DGifGetExtensionNext(GifFile, Extension);
550 DGifGetExtensionNext(GifFileType *GifFile, GifByteType ** Extension)
553 GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
555 if (READ(GifFile, &Buf, 1) != 1) {
556 GifFile->Error = D_GIF_ERR_READ_FAILED;
563 if (READ(GifFile, &((*Extension)[1]), Buf) != Buf) {
564 GifFile->Error = D_GIF_ERR_READ_FAILED;
600 int DGifSavedExtensionToGCB(GifFileType *GifFile,
605 if (ImageIndex < 0 || ImageIndex > GifFile->ImageCount - 1)
613 for (i = 0; i < GifFile->SavedImages[ImageIndex].ExtensionBlockCount; i++) {
614 ExtensionBlock *ep = &GifFile->SavedImages[ImageIndex].ExtensionBlocks[i];
626 DGifCloseFile(GifFileType *GifFile, int *ErrorCode)
630 if (GifFile == NULL || GifFile->Private == NULL)
633 if (GifFile->Image.ColorMap) {
634 GifFreeMapObject(GifFile->Image.ColorMap);
635 GifFile->Image.ColorMap = NULL;
638 if (GifFile->SColorMap) {
639 GifFreeMapObject(GifFile->SColorMap);
640 GifFile->SColorMap = NULL;
643 if (GifFile->SavedImages) {
644 GifFreeSavedImages(GifFile);
645 GifFile->SavedImages = NULL;
648 GifFreeExtensions(&GifFile->ExtensionBlockCount, &GifFile->ExtensionBlocks);
650 Private = (GifFilePrivateType *) GifFile->Private;
656 free((char *)GifFile->Private);
657 free(GifFile);
664 free((char *)GifFile->Private);
665 free(GifFile);
669 free((char *)GifFile->Private);
670 free(GifFile);
680 DGifGetWord(GifFileType *GifFile, GifWord *Word)
685 if (READ(GifFile, c, 2) != 2) {
686 GifFile->Error = D_GIF_ERR_READ_FAILED;
702 DGifGetCode(GifFileType *GifFile, int *CodeSize, GifByteType **CodeBlock)
704 GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
708 GifFile->Error = D_GIF_ERR_NOT_READABLE;
714 return DGifGetCodeNext(GifFile, CodeBlock);
723 DGifGetCodeNext(GifFileType *GifFile, GifByteType **CodeBlock)
726 GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
730 if (READ(GifFile, &Buf, 1) != 1) {
731 GifFile->Error = D_GIF_ERR_READ_FAILED;
740 if (READ(GifFile, &((*CodeBlock)[1]), Buf) != Buf) {
741 GifFile->Error = D_GIF_ERR_READ_FAILED;
757 DGifSetupDecompress(GifFileType *GifFile)
762 GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
765 if (READ(GifFile, &CodeSize, 1) < 1) { /* Read Code size from file. */
772 GifFile->Error = D_GIF_ERR_READ_FAILED; /* somewhat bogus error code */
802 DGifDecompressLine(GifFileType *GifFile, GifPixelType *Line, int LineLen)
808 GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;
829 if (DGifDecompressInput(GifFile, &CrntCode) == GIF_ERROR)
836 GifFile->Error = D_GIF_ERR_EOF_TOO_SOON;
889 GifFile->Error = D_GIF_ERR_IMAGE_DEFECT;
949 DGifGetLZCodes(GifFileType *GifFile, int *Code)
952 GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
956 GifFile->Error = D_GIF_ERR_NOT_READABLE;
960 if (DGifDecompressInput(GifFile, Code) == GIF_ERROR)
966 if (DGifGetCodeNext(GifFile, &CodeBlock) == GIF_ERROR)
988 DGifDecompressInput(GifFileType *GifFile, int *Code)
997 GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
1003 GifFile->Error = D_GIF_ERR_IMAGE_DEFECT;
1009 if (DGifBufferedInput(GifFile, Private->Buf, &NextByte) == GIF_ERROR) {
1042 DGifBufferedInput(GifFileType *GifFile, GifByteType *Buf, GifByteType *NextByte)
1047 if (READ(GifFile, Buf, 1) != 1) {
1048 GifFile->Error = D_GIF_ERR_READ_FAILED;
1056 GifFile->Error = D_GIF_ERR_IMAGE_DEFECT;
1059 if (READ(GifFile, &Buf[1], Buf[0]) != Buf[0]) {
1060 GifFile->Error = D_GIF_ERR_READ_FAILED;
1080 DGifSlurp(GifFileType *GifFile)
1088 GifFile->ExtensionBlocks = NULL;
1089 GifFile->ExtensionBlockCount = 0;
1092 if (DGifGetRecordType(GifFile, &RecordType) == GIF_ERROR)
1097 if (DGifGetImageDesc(GifFile) == GIF_ERROR)
1100 sp = &GifFile->SavedImages[GifFile->ImageCount - 1];
1131 if (DGifGetLine(GifFile,
1138 if (DGifGetLine(GifFile,sp->RasterBits,ImageSize)==GIF_ERROR)
1142 if (GifFile->ExtensionBlocks) {
1143 sp->ExtensionBlocks = GifFile->ExtensionBlocks;
1144 sp->ExtensionBlockCount = GifFile->ExtensionBlockCount;
1146 GifFile->ExtensionBlocks = NULL;
1147 GifFile->ExtensionBlockCount = 0;
1152 if (DGifGetExtension(GifFile,&ExtFunction,&ExtData) == GIF_ERROR)
1156 if (GifAddExtensionBlock(&GifFile->ExtensionBlockCount,
1157 &GifFile->ExtensionBlocks,
1163 if (DGifGetExtensionNext(GifFile, &ExtData) == GIF_ERROR)
1167 if (GifAddExtensionBlock(&GifFile->ExtensionBlockCount,
1168 &GifFile->ExtensionBlocks,
1184 if (GifFile->ImageCount == 0) {
1185 GifFile->Error = D_GIF_ERR_NO_IMAG_DSCR;