| 1 | /** |
| 2 | * @file gifread.h |
| 3 | * A plain and simple GIF reader. |
| 4 | * |
| 5 | * @copyright |
| 6 | * |
| 7 | * Copyright (C) 2003-2025 Cosmin Truta and the Contributing Authors. |
| 8 | * |
| 9 | * This software was derived from "giftopnm.c" by David Koblas, |
| 10 | * and is distributed under the same copyright and warranty terms |
| 11 | * as the original software. |
| 12 | * |
| 13 | * Copyright 1990 - 1994, David Koblas. ([email protected]) |
| 14 | * |
| 15 | * Permission to use, copy, modify, and distribute this software |
| 16 | * and its documentation for any purpose and without fee is hereby |
| 17 | * granted, provided that the above copyright notice appear in all |
| 18 | * copies and that both that copyright notice and this permission |
| 19 | * notice appear in supporting documentation. This software is |
| 20 | * provided "as is" without express or implied warranty. |
| 21 | * |
| 22 | * @bug GIF/LZW decoding is not reentrant. |
| 23 | **/ |
| 24 | |
| 25 | #ifndef GIFREAD_H_ |
| 26 | #define GIFREAD_H_cxx . . $ `third_party/gifread/gifread.h:26:9`! |
| 27 | |
| 28 | #include <stdio.h> |
| 29 | |
| 30 | |
| 31 | #ifdef __cplusplus |
| 32 | extern "C" { |
| 33 | #endif |
| 34 | |
| 35 | |
| 36 | #define GIF_PLAINTEXTcxx . . $ `third_party/gifread/gifread.h:36:9`! 0x01 |
| 37 | #define GIF_EXTENSIONcxx . . $ `third_party/gifread/gifread.h:37:9`! 0x21 /* '!' */ |
| 38 | #define GIF_IMAGEcxx . . $ `third_party/gifread/gifread.h:38:9`! 0x2c /* ',' */ |
| 39 | #define GIF_TERMINATORcxx . . $ `third_party/gifread/gifread.h:39:9`! 0x3b /* ';' */ |
| 40 | #define GIF_GRAPHICCTLcxx . . $ `third_party/gifread/gifread.h:40:9`! 0xf9 |
| 41 | #define GIF_COMMENTcxx . . $ `third_party/gifread/gifread.h:41:9`! 0xfe |
| 42 | #define GIF_APPLICATIONcxx . . $ `third_party/gifread/gifread.h:42:9`! 0xff |
| 43 | |
| 44 | #define GIF_NUMCOLORS_MAXcxx . . $ `third_party/gifread/gifread.h:44:9`! 256 |
| 45 | |
| 46 | #define GIF_IND_REDcxx . . $ `third_party/gifread/gifread.h:46:9`! 0 |
| 47 | #define GIF_IND_GREENcxx . . $ `third_party/gifread/gifread.h:47:9`! 1 |
| 48 | #define GIF_IND_BLUEcxx . . $ `third_party/gifread/gifread.h:48:9`! 2 |
| 49 | |
| 50 | |
| 51 | /** |
| 52 | * The GIF screen structure. |
| 53 | **/ |
| 54 | struct GIFScreencxx . . $ GIFScreen# |
| 55 | { |
| 56 | unsigned int Widthcxx . . $ GIFScreen#Width.; |
| 57 | unsigned int Heightcxx . . $ GIFScreen#Height.; |
| 58 | unsigned int GlobalColorFlagcxx . . $ GIFScreen#GlobalColorFlag.; |
| 59 | unsigned int ColorResolutioncxx . . $ GIFScreen#ColorResolution.; |
| 60 | unsigned int SortFlagcxx . . $ GIFScreen#SortFlag.; |
| 61 | unsigned int GlobalNumColorscxx . . $ GIFScreen#GlobalNumColors.; |
| 62 | unsigned int Backgroundcxx . . $ GIFScreen#Background.; |
| 63 | unsigned int PixelAspectRatiocxx . . $ GIFScreen#PixelAspectRatio.; |
| 64 | unsigned char GlobalColorTablecxx . . $ GIFScreen#GlobalColorTable.[GIF_NUMCOLORS_MAXcxx . . $ `third_party/gifread/gifread.h:44:9`! * 3]; |
| 65 | }; |
| 66 | |
| 67 | /** |
| 68 | * The GIF image structure. |
| 69 | **/ |
| 70 | struct GIFImagecxx . . $ GIFImage# |
| 71 | { |
| 72 | struct GIFScreencxx . . $ GIFScreen# *Screencxx . . $ GIFImage#Screen.; |
| 73 | unsigned int LeftPoscxx . . $ GIFImage#LeftPos.; |
| 74 | unsigned int TopPoscxx . . $ GIFImage#TopPos.; |
| 75 | unsigned int Widthcxx . . $ GIFImage#Width.; |
| 76 | unsigned int Heightcxx . . $ GIFImage#Height.; |
| 77 | unsigned int LocalColorFlagcxx . . $ GIFImage#LocalColorFlag.; |
| 78 | unsigned int InterlaceFlagcxx . . $ GIFImage#InterlaceFlag.; |
| 79 | unsigned int SortFlagcxx . . $ GIFImage#SortFlag.; |
| 80 | unsigned int LocalNumColorscxx . . $ GIFImage#LocalNumColors.; |
| 81 | unsigned char LocalColorTablecxx . . $ GIFImage#LocalColorTable.[GIF_NUMCOLORS_MAXcxx . . $ `third_party/gifread/gifread.h:44:9`! * 3]; |
| 82 | unsigned char **Rowscxx . . $ GIFImage#Rows.; |
| 83 | }; |
| 84 | |
| 85 | /** |
| 86 | * The GIF extension structure. |
| 87 | **/ |
| 88 | struct GIFExtensioncxx . . $ GIFExtension# |
| 89 | { |
| 90 | struct GIFScreencxx . . $ GIFScreen# *Screencxx . . $ GIFExtension#Screen.; |
| 91 | unsigned char *Buffercxx . . $ GIFExtension#Buffer.; |
| 92 | unsigned int BufferSizecxx . . $ GIFExtension#BufferSize.; |
| 93 | unsigned char Labelcxx . . $ GIFExtension#Label.; |
| 94 | }; |
| 95 | |
| 96 | /** |
| 97 | * The GIF graphic control extension structure. |
| 98 | **/ |
| 99 | struct GIFGraphicCtlExtcxx . . $ GIFGraphicCtlExt# |
| 100 | { |
| 101 | unsigned int DisposalMethodcxx . . $ GIFGraphicCtlExt#DisposalMethod.; |
| 102 | unsigned int InputFlagcxx . . $ GIFGraphicCtlExt#InputFlag.; |
| 103 | unsigned int TransparentFlagcxx . . $ GIFGraphicCtlExt#TransparentFlag.; |
| 104 | unsigned int DelayTimecxx . . $ GIFGraphicCtlExt#DelayTime.; |
| 105 | unsigned int Transparentcxx . . $ GIFGraphicCtlExt#Transparent.; |
| 106 | }; |
| 107 | |
| 108 | |
| 109 | /** |
| 110 | * Reads the GIF screen and the global color table. |
| 111 | * @param screen the destination screen object |
| 112 | * @param stream a file stream |
| 113 | **/ |
| 114 | void GIFReadScreencxx . . $ GIFReadScreen(cda1c5bcbeb2a4f0).(struct GIFScreencxx . . $ GIFScreen# *screen, FILEcxx . . $ FILE# *stream); |
| 115 | |
| 116 | /** |
| 117 | * Initializes a GIF image object. |
| 118 | * @param image the resulting image object |
| 119 | * @param screen a screen object |
| 120 | * @param rows an array of rows; can be NULL |
| 121 | **/ |
| 122 | void GIFInitImagecxx . . $ GIFInitImage(c956e24543cc1768).(struct GIFImagecxx . . $ GIFImage# *image, |
| 123 | struct GIFScreencxx . . $ GIFScreen# *screen, unsigned char **rows); |
| 124 | |
| 125 | /** |
| 126 | * Destroys a GIF image object. |
| 127 | * @param image an image object |
| 128 | **/ |
| 129 | void GIFDestroyImagecxx . . $ GIFDestroyImage(2b71ea1026988ece).(struct GIFImagecxx . . $ GIFImage# *image); |
| 130 | |
| 131 | /** |
| 132 | * Reads the next GIF block into an image or extension object. |
| 133 | * @param image the destination image object; can be NULL |
| 134 | * @param ext the destination extension object; can be NULL |
| 135 | * @param stream a file stream |
| 136 | * @return the block code |
| 137 | **/ |
| 138 | int GIFReadNextBlockcxx . . $ GIFReadNextBlock(3a398aa393699901).(struct GIFImagecxx . . $ GIFImage# *image, struct GIFExtensioncxx . . $ GIFExtension# *ext, |
| 139 | FILEcxx . . $ FILE# *stream); |
| 140 | |
| 141 | /** |
| 142 | * Returns the local or the global color table (whichever is applicable), |
| 143 | * or a predefined color table if both of these tables are missing. |
| 144 | * @param colors the resulting color table |
| 145 | * @param numColors the size of the resulting color table |
| 146 | * @param image an image object |
| 147 | **/ |
| 148 | void GIFGetColorTablecxx . . $ GIFGetColorTable(8d439245f2d7e9d7).(unsigned char **colors, unsigned int *numColors, |
| 149 | struct GIFImagecxx . . $ GIFImage# *image); |
| 150 | |
| 151 | /** |
| 152 | * Initializes a GIF extension object. |
| 153 | * @param ext the resulting extension object |
| 154 | * @param screen a screen object |
| 155 | * @param initBufferSize an initial buffer size; can be 0 |
| 156 | **/ |
| 157 | void GIFInitExtensioncxx . . $ GIFInitExtension(229c763ec06d9c9f).(struct GIFExtensioncxx . . $ GIFExtension# *ext, |
| 158 | struct GIFScreencxx . . $ GIFScreen# *screen, unsigned int initBufferSize); |
| 159 | |
| 160 | /** |
| 161 | * Destroys a GIF extension object. |
| 162 | * @param ext an extension object |
| 163 | **/ |
| 164 | void GIFDestroyExtensioncxx . . $ GIFDestroyExtension(672ae7e3e0e148a4).(struct GIFExtensioncxx . . $ GIFExtension# *ext); |
| 165 | |
| 166 | /** |
| 167 | * Constructs a GIF graphic control extension object |
| 168 | * from a raw extension object. |
| 169 | * @param graphicExt the resulting graphic control extension object |
| 170 | * @param ext a raw extension object |
| 171 | **/ |
| 172 | void GIFGetGraphicCtlcxx . . $ GIFGetGraphicCtl(d115dbec00c89685).(struct GIFGraphicCtlExtcxx . . $ GIFGraphicCtlExt# *graphicExt, |
| 173 | struct GIFExtensioncxx . . $ GIFExtension# *ext); |
| 174 | |
| 175 | |
| 176 | /** |
| 177 | * The error handling callback. |
| 178 | * @param message an error message |
| 179 | **/ |
| 180 | extern void (*GIFErrorcxx . . $ GIFError.)(const char *message); |
| 181 | |
| 182 | /** |
| 183 | * The warning handling callback. |
| 184 | * @param message a warning message |
| 185 | **/ |
| 186 | extern void (*GIFWarningcxx . . $ GIFWarning.)(const char *message); |
| 187 | |
| 188 | |
| 189 | #ifdef __cplusplus |
| 190 | } /* extern "C" */ |
| 191 | #endif |
| 192 | |
| 193 | |
| 194 | #endif /* GIFREAD_H_ */ |