ReactOS 0.4.16-dev-297-gc569aee
ungif.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  GifColorType
 
struct  ColorMapObject
 
struct  GifImageDesc
 
struct  ExtensionBlock
 
struct  Extensions
 
struct  GifFileType
 
struct  SavedImage
 

Macros

#define GIF_ERROR   0
 
#define GIF_OK   1
 
#define TRUE   1
 
#define FALSE   0
 
#define NULL   0
 
#define GIF_STAMP   "GIFVER" /* First chars in file - GIF stamp. */
 
#define GIF_STAMP_LEN   sizeof(GIF_STAMP) - 1
 
#define GIF_VERSION_POS   3 /* Version first character in stamp. */
 
#define GIF87_STAMP   "GIF87a" /* First chars in file - GIF stamp. */
 
#define GIF89_STAMP   "GIF89a" /* First chars in file - GIF stamp. */
 
#define GIF_FILE_BUFFER_SIZE   16384 /* Files uses bigger buffers than usual. */
 
#define COMMENT_EXT_FUNC_CODE   0xfe /* comment */
 
#define GRAPHICS_EXT_FUNC_CODE   0xf9 /* graphics control */
 
#define PLAINTEXT_EXT_FUNC_CODE   0x01 /* plaintext */
 
#define APPLICATION_EXT_FUNC_CODE   0xff /* application block */
 
#define D_GIF_ERR_OPEN_FAILED   101 /* And DGif possible errors. */
 
#define D_GIF_ERR_READ_FAILED   102
 
#define D_GIF_ERR_NOT_GIF_FILE   103
 
#define D_GIF_ERR_NO_SCRN_DSCR   104
 
#define D_GIF_ERR_NO_IMAG_DSCR   105
 
#define D_GIF_ERR_NO_COLOR_MAP   106
 
#define D_GIF_ERR_WRONG_RECORD   107
 
#define D_GIF_ERR_DATA_TOO_BIG   108
 
#define D_GIF_ERR_NOT_ENOUGH_MEM   109
 
#define D_GIF_ERR_CLOSE_FAILED   110
 
#define D_GIF_ERR_NOT_READABLE   111
 
#define D_GIF_ERR_IMAGE_DEFECT   112
 
#define D_GIF_ERR_EOF_TOO_SOON   113
 

Typedefs

typedef int GifBooleanType
 
typedef unsigned char GifPixelType
 
typedef unsigned charGifRowType
 
typedef unsigned char GifByteType
 
typedef unsigned int GifPrefixType
 
typedef int GifWord
 
typedef struct GifColorType GifColorType
 
typedef struct ColorMapObject ColorMapObject
 
typedef struct GifImageDesc GifImageDesc
 
typedef struct GifFileType GifFileType
 
typedef int(* InputFunc) (GifFileType *, GifByteType *, int)
 
typedef struct SavedImage SavedImage
 

Enumerations

enum  GifRecordType {
  UNDEFINED_RECORD_TYPE , SCREEN_DESC_RECORD_TYPE , IMAGE_DESC_RECORD_TYPE , EXTENSION_RECORD_TYPE ,
  TERMINATE_RECORD_TYPE
}
 

Functions

int DGifSlurp (GifFileType *GifFile) DECLSPEC_HIDDEN
 
GifFileTypeDGifOpen (void *userPtr, InputFunc readFunc) DECLSPEC_HIDDEN
 
int DGifCloseFile (GifFileType *GifFile) DECLSPEC_HIDDEN
 

Macro Definition Documentation

◆ APPLICATION_EXT_FUNC_CODE

#define APPLICATION_EXT_FUNC_CODE   0xff /* application block */

Definition at line 144 of file ungif.h.

◆ COMMENT_EXT_FUNC_CODE

#define COMMENT_EXT_FUNC_CODE   0xfe /* comment */

Definition at line 141 of file ungif.h.

◆ D_GIF_ERR_CLOSE_FAILED

#define D_GIF_ERR_CLOSE_FAILED   110

Definition at line 160 of file ungif.h.

◆ D_GIF_ERR_DATA_TOO_BIG

#define D_GIF_ERR_DATA_TOO_BIG   108

Definition at line 158 of file ungif.h.

◆ D_GIF_ERR_EOF_TOO_SOON

#define D_GIF_ERR_EOF_TOO_SOON   113

Definition at line 163 of file ungif.h.

◆ D_GIF_ERR_IMAGE_DEFECT

#define D_GIF_ERR_IMAGE_DEFECT   112

Definition at line 162 of file ungif.h.

◆ D_GIF_ERR_NO_COLOR_MAP

#define D_GIF_ERR_NO_COLOR_MAP   106

Definition at line 156 of file ungif.h.

◆ D_GIF_ERR_NO_IMAG_DSCR

#define D_GIF_ERR_NO_IMAG_DSCR   105

Definition at line 155 of file ungif.h.

◆ D_GIF_ERR_NO_SCRN_DSCR

#define D_GIF_ERR_NO_SCRN_DSCR   104

Definition at line 154 of file ungif.h.

◆ D_GIF_ERR_NOT_ENOUGH_MEM

#define D_GIF_ERR_NOT_ENOUGH_MEM   109

Definition at line 159 of file ungif.h.

◆ D_GIF_ERR_NOT_GIF_FILE

#define D_GIF_ERR_NOT_GIF_FILE   103

Definition at line 153 of file ungif.h.

◆ D_GIF_ERR_NOT_READABLE

#define D_GIF_ERR_NOT_READABLE   111

Definition at line 161 of file ungif.h.

◆ D_GIF_ERR_OPEN_FAILED

#define D_GIF_ERR_OPEN_FAILED   101 /* And DGif possible errors. */

Definition at line 151 of file ungif.h.

◆ D_GIF_ERR_READ_FAILED

#define D_GIF_ERR_READ_FAILED   102

Definition at line 152 of file ungif.h.

◆ D_GIF_ERR_WRONG_RECORD

#define D_GIF_ERR_WRONG_RECORD   107

Definition at line 157 of file ungif.h.

◆ FALSE

#define FALSE   0

Definition at line 62 of file ungif.h.

◆ GIF87_STAMP

#define GIF87_STAMP   "GIF87a" /* First chars in file - GIF stamp. */

Definition at line 72 of file ungif.h.

◆ GIF89_STAMP

#define GIF89_STAMP   "GIF89a" /* First chars in file - GIF stamp. */

Definition at line 73 of file ungif.h.

◆ GIF_ERROR

#define GIF_ERROR   0

Definition at line 55 of file ungif.h.

◆ GIF_FILE_BUFFER_SIZE

#define GIF_FILE_BUFFER_SIZE   16384 /* Files uses bigger buffers than usual. */

Definition at line 75 of file ungif.h.

◆ GIF_OK

#define GIF_OK   1

Definition at line 56 of file ungif.h.

◆ GIF_STAMP

#define GIF_STAMP   "GIFVER" /* First chars in file - GIF stamp. */

Definition at line 69 of file ungif.h.

◆ GIF_STAMP_LEN

#define GIF_STAMP_LEN   sizeof(GIF_STAMP) - 1

Definition at line 70 of file ungif.h.

◆ GIF_VERSION_POS

#define GIF_VERSION_POS   3 /* Version first character in stamp. */

Definition at line 71 of file ungif.h.

◆ GRAPHICS_EXT_FUNC_CODE

#define GRAPHICS_EXT_FUNC_CODE   0xf9 /* graphics control */

Definition at line 142 of file ungif.h.

◆ NULL

#define NULL   0

Definition at line 66 of file ungif.h.

◆ PLAINTEXT_EXT_FUNC_CODE

#define PLAINTEXT_EXT_FUNC_CODE   0x01 /* plaintext */

Definition at line 143 of file ungif.h.

◆ TRUE

#define TRUE   1

Definition at line 59 of file ungif.h.

Typedef Documentation

◆ ColorMapObject

◆ GifBooleanType

Definition at line 77 of file ungif.h.

◆ GifByteType

Definition at line 80 of file ungif.h.

◆ GifColorType

◆ GifFileType

◆ GifImageDesc

◆ GifPixelType

Definition at line 78 of file ungif.h.

◆ GifPrefixType

Definition at line 81 of file ungif.h.

◆ GifRowType

Definition at line 79 of file ungif.h.

◆ GifWord

typedef int GifWord

Definition at line 82 of file ungif.h.

◆ InputFunc

typedef int(* InputFunc) (GifFileType *, GifByteType *, int)

Definition at line 137 of file ungif.h.

◆ SavedImage

Enumeration Type Documentation

◆ GifRecordType

Enumerator
UNDEFINED_RECORD_TYPE 
SCREEN_DESC_RECORD_TYPE 
IMAGE_DESC_RECORD_TYPE 
EXTENSION_RECORD_TYPE 
TERMINATE_RECORD_TYPE 

Definition at line 128 of file ungif.h.

128 {
131 IMAGE_DESC_RECORD_TYPE, /* Begin with ',' */
132 EXTENSION_RECORD_TYPE, /* Begin with '!' */
133 TERMINATE_RECORD_TYPE /* Begin with ';' */
GifRecordType
Definition: ungif.h:128
@ EXTENSION_RECORD_TYPE
Definition: ungif.h:132
@ UNDEFINED_RECORD_TYPE
Definition: ungif.h:129
@ IMAGE_DESC_RECORD_TYPE
Definition: ungif.h:131
@ TERMINATE_RECORD_TYPE
Definition: ungif.h:133
@ SCREEN_DESC_RECORD_TYPE
Definition: ungif.h:130

Function Documentation

◆ DGifCloseFile()

int DGifCloseFile ( GifFileType GifFile)

Definition at line 1047 of file ungif.c.

1047 {
1048
1049 GifFilePrivateType *Private;
1050
1051 if (GifFile == NULL)
1052 return GIF_ERROR;
1053
1054 Private = GifFile->Private;
1055
1056 if (GifFile->Image.ColorMap) {
1057 FreeMapObject(GifFile->Image.ColorMap);
1058 GifFile->Image.ColorMap = NULL;
1059 }
1060
1061 if (GifFile->SColorMap) {
1062 FreeMapObject(GifFile->SColorMap);
1063 GifFile->SColorMap = NULL;
1064 }
1065
1066 ungif_free(Private);
1067 Private = NULL;
1068
1069 if (GifFile->SavedImages) {
1070 FreeSavedImages(GifFile);
1071 GifFile->SavedImages = NULL;
1072 }
1073
1074 FreeExtension(&GifFile->Extensions);
1075
1076 ungif_free(GifFile);
1077
1078 return GIF_OK;
1079}
#define NULL
Definition: types.h:112
Extensions Extensions
Definition: ungif.h:120
GifImageDesc Image
Definition: ungif.h:122
struct SavedImage * SavedImages
Definition: ungif.h:123
ColorMapObject * SColorMap
Definition: ungif.h:119
void * Private
Definition: ungif.h:125
ColorMapObject * ColorMap
Definition: ungif.h:98
static void FreeMapObject(ColorMapObject *Object)
Definition: ungif.c:182
static void FreeExtension(Extensions *Extensions)
Definition: ungif.c:260
static void ungif_free(void *ptr)
Definition: ungif.c:76
static void FreeSavedImages(GifFileType *GifFile)
Definition: ungif.c:279
#define GIF_OK
Definition: ungif.h:56
#define GIF_ERROR
Definition: ungif.h:55

Referenced by GifDecoder_Release().

◆ DGifOpen()

GifFileType * DGifOpen ( void userPtr,
InputFunc  readFunc 
)

Definition at line 993 of file ungif.c.

994 {
995
996 unsigned char Buf[GIF_STAMP_LEN + 1];
997 GifFileType *GifFile;
998 GifFilePrivateType *Private;
999
1000 GifFile = ungif_alloc(sizeof(GifFileType));
1001 if (GifFile == NULL) {
1002 return NULL;
1003 }
1004
1005 memset(GifFile, '\0', sizeof(GifFileType));
1006
1007 Private = ungif_alloc(sizeof(GifFilePrivateType));
1008 if (!Private) {
1009 ungif_free(GifFile);
1010 return NULL;
1011 }
1012
1013 GifFile->Private = (void*)Private;
1014
1015 Private->Read = readFunc; /* TVT */
1016 GifFile->UserData = userData; /* TVT */
1017
1018 /* Lets see if this is a GIF file: */
1019 if (READ(GifFile, Buf, GIF_STAMP_LEN) != GIF_STAMP_LEN) {
1020 ungif_free(Private);
1021 ungif_free(GifFile);
1022 return NULL;
1023 }
1024
1025 /* The GIF Version number is ignored at this time. Maybe we should do
1026 * something more useful with it. */
1027 Buf[GIF_STAMP_LEN] = 0;
1028 if (memcmp(GIF_STAMP, Buf, GIF_VERSION_POS) != 0) {
1029 ungif_free(Private);
1030 ungif_free(GifFile);
1031 return NULL;
1032 }
1033
1034 if (DGifGetScreenDesc(GifFile) == GIF_ERROR) {
1035 ungif_free(Private);
1036 ungif_free(GifFile);
1037 return NULL;
1038 }
1039
1040 return GifFile;
1041}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define memset(x, y, z)
Definition: compat.h:39
InputFunc Read
Definition: ungif.c:99
void * UserData
Definition: ungif.h:124
static int DGifGetScreenDesc(GifFileType *GifFile)
Definition: ungif.c:307
#define READ(_gif, _buf, _len)
Definition: ungif.c:107
static void * ungif_alloc(size_t sz)
Definition: ungif.c:61
#define GIF_VERSION_POS
Definition: ungif.h:71
#define GIF_STAMP_LEN
Definition: ungif.h:70
#define GIF_STAMP
Definition: ungif.h:69

Referenced by GifDecoder_Initialize().

◆ DGifSlurp()

int DGifSlurp ( GifFileType GifFile)

Definition at line 876 of file ungif.c.

876 {
877
878 int ImageSize;
879 GifRecordType RecordType;
880 SavedImage *sp;
881 GifByteType *ExtData;
882 Extensions temp_save;
883
884 temp_save.ExtensionBlocks = NULL;
885 temp_save.ExtensionBlockCount = 0;
886
887 do {
888 if (DGifGetRecordType(GifFile, &RecordType) == GIF_ERROR)
889 return (GIF_ERROR);
890
891 switch (RecordType) {
893 if (DGifGetImageDesc(GifFile) == GIF_ERROR)
894 return (GIF_ERROR);
895
896 sp = &GifFile->SavedImages[GifFile->ImageCount - 1];
897 ImageSize = sp->ImageDesc.Width * sp->ImageDesc.Height;
898
899 sp->RasterBits = ungif_alloc(ImageSize * sizeof(GifPixelType));
900 if (sp->RasterBits == NULL) {
901 return GIF_ERROR;
902 }
903 if (DGifGetLine(GifFile, sp->RasterBits, ImageSize) ==
904 GIF_ERROR)
905 return (GIF_ERROR);
906 if (temp_save.ExtensionBlocks) {
907 sp->Extensions.ExtensionBlocks = temp_save.ExtensionBlocks;
908 sp->Extensions.ExtensionBlockCount = temp_save.ExtensionBlockCount;
909
910 temp_save.ExtensionBlocks = NULL;
911 temp_save.ExtensionBlockCount = 0;
912
913 /* FIXME: The following is wrong. It is left in only for
914 * backwards compatibility. Someday it should go away. Use
915 * the sp->ExtensionBlocks->Function variable instead. */
916 sp->Extensions.Function = sp->Extensions.ExtensionBlocks[0].Function;
917 }
918 break;
919
921 {
922 int Function;
924
925 if (DGifGetExtension(GifFile, &Function, &ExtData) == GIF_ERROR)
926 return (GIF_ERROR);
927
928 if (GifFile->ImageCount || Function == GRAPHICS_EXT_FUNC_CODE)
929 Extensions = &temp_save;
930 else
931 Extensions = &GifFile->Extensions;
932
934
935 if (ExtData)
936 {
937 /* Create an extension block with our data */
938 if (AddExtensionBlock(Extensions, ExtData[0], &ExtData[1]) == GIF_ERROR)
939 return (GIF_ERROR);
940 }
941 else /* Empty extension block */
942 {
944 return (GIF_ERROR);
945 }
946
947 while (ExtData != NULL) {
948 int Len;
950
951 if (DGifGetExtensionNext(GifFile, &ExtData) == GIF_ERROR)
952 return (GIF_ERROR);
953
954 if (ExtData)
955 {
956 Len = ExtData[0];
957 Data = &ExtData[1];
958 }
959 else
960 {
961 Len = 0;
962 Data = NULL;
963 }
964
966 return (GIF_ERROR);
967 }
968 break;
969 }
970
972 break;
973
974 default: /* Should be trapped by DGifGetRecordType */
975 break;
976 }
977 } while (RecordType != TERMINATE_RECORD_TYPE);
978
979 /* Just in case the Gif has an extension block without an associated
980 * image... (Should we save this into a savefile structure with no image
981 * instead? Have to check if the present writing code can handle that as
982 * well.... */
983 if (temp_save.ExtensionBlocks)
984 FreeExtension(&temp_save);
985
986 return (GIF_OK);
987}
_In_ CDROM_SCAN_FOR_SPECIAL_INFO _In_ PCDROM_SCAN_FOR_SPECIAL_HANDLER Function
Definition: cdrom.h:1156
#define Len
Definition: deflate.h:82
static const WCHAR sp[]
Definition: suminfo.c:287
int Function
Definition: ungif.h:109
ExtensionBlock * ExtensionBlocks
Definition: ungif.h:111
int ExtensionBlockCount
Definition: ungif.h:110
int ImageCount
Definition: ungif.h:121
static int DGifGetExtension(GifFileType *GifFile, int *ExtCode, GifByteType **Extension)
Definition: ungif.c:515
static int AppendExtensionBlock(Extensions *New, int Len, const unsigned char ExtData[])
Definition: ungif.c:234
static int DGifGetRecordType(GifFileType *GifFile, GifRecordType *Type)
Definition: ungif.c:355
static int DGifGetImageDesc(GifFileType *GifFile)
Definition: ungif.c:390
static int AddExtensionBlock(Extensions *New, int Len, const unsigned char ExtData[])
Definition: ungif.c:197
static int DGifGetLine(GifFileType *GifFile, GifPixelType *Line, int LineLen)
Definition: ungif.c:475
static int DGifGetExtensionNext(GifFileType *GifFile, GifByteType **GifExtension)
Definition: ungif.c:535
unsigned char GifPixelType
Definition: ungif.h:78
unsigned char GifByteType
Definition: ungif.h:80
#define GRAPHICS_EXT_FUNC_CODE
Definition: ungif.h:142

Referenced by GifDecoder_Initialize().