FileUtils.c: fix CERT VU#575804
[oweals/cde.git] / cde / lib / DtHelp / GifUtilsI.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: GifUtilsI.h /main/3 1996/05/09 03:42:55 drk $ */
24 #ifndef _DtGifUtilsI_h
25 #define _DtGifUtilsI_h
26
27 /* Include files */
28 #include <X11/Xlib.h>
29 #include "GraphicsP.h"
30
31 /* Enumerated values */
32 enum op_t { DO_COLOR, DO_GREY };
33
34 /* Type definitions */
35 typedef unsigned char byte;
36 typedef unsigned long pixel;
37
38 /* Data structures */
39
40 typedef struct 
41   {
42     unsigned long pixel;
43     unsigned short red, green, blue;
44     unsigned short grey;
45   } GifColors;
46
47 typedef struct 
48 {
49   XImage        *f_ximage;
50   Display       *f_dpy;
51   int            f_screen;
52   Colormap       f_cmap;
53   Drawable       f_drawable;
54   GC             f_gc;
55   Visual        *f_visual;
56   unsigned int   f_ncells;
57   unsigned int   f_nplanes;
58   unsigned long  f_black;
59   unsigned long  f_white;
60   unsigned long  f_fg;
61   unsigned long  f_bg;
62   int            f_dft_depth;
63   int            f_visual_class;
64   int            f_color_map_constructed;
65   int            f_do_visual;
66   int            bits_per_pixel ;  
67   int            colors_per_pixel;
68   int            total_colors ; 
69   int            f_total_greys;
70   int            f_init_total_greys;  
71   Boolean        f_allow_reduced_colors;
72   Boolean        f_color_reduction_used;     
73   GifColors      GifCMap[64];
74   unsigned long  GifGMap[32];
75 } GifObj;
76
77 /* Function prototypes */
78
79 /* Initializes a gif object structure */
80 enum _DtGrLoadStatus InitGifObject( 
81     GifObj                *g, 
82     Display               *dpy, 
83     Drawable               drawable, 
84     Screen                *screen,
85     int                    depth, 
86     Colormap               colormap, 
87     Visual                *visual, 
88     GC                     gc,
89     enum _DtGrColorModel   colorModel, 
90     Boolean                allowReducedColors
91 );
92
93 /* Deletes resources associated with a gif object structure */
94 void DeleteGifObjectResources(
95     GifObj *g 
96 );
97
98 /* Converts a gif buffer to an X pixmap */
99 Pixmap gif_to_pixmap(
100     GifObj        *g, 
101     byte          *inbuf, 
102     unsigned int   buflen, 
103     Dimension     *w, 
104     Dimension     *h, 
105     Pixel          fg, 
106     Pixel          bg,
107     float          ratio
108 );
109
110 /* Creates a raw PPM-style image from a GIF buffer */
111 pixel **create_raw_image(
112     byte          *inbuf, 
113     unsigned int   buflen, 
114     int           *width, 
115     int           *height, 
116     int            imageNumber
117 );
118
119 /* Creates an X pixmap from a raw PPM-style image */
120 Pixmap create_pixmap(
121     GifObj    *g, 
122     pixel   **image, 
123     int        width, 
124     int        height, 
125     Pixel      fg, 
126     Pixel      bg,
127     float      ratio
128 );
129
130 /* Frees raw image data */
131 void free_raw_image(
132     pixel  **image
133 );
134
135 /* Allocates X pixels needed for the color cube */
136 int allocate_colors(
137     GifObj  *g
138 );
139
140 /* Allocates X pixels needed for greyscale rendering */
141 int allocate_greys(
142     GifObj  *g
143 );
144
145 #endif /* _DtGifUtilsI_h */
146 /* DON'T ADD ANYTHING AFTER THIS #endif */